Quellcode durchsuchen

Support publishing files

Adds new `writeas publish <file>` command
pull/21/head
Matt Baer vor 5 Jahren
Ursprung
Commit
a83410b717
4 geänderte Dateien mit 21 neuen und 0 gelöschten Zeilen
  1. +1
    -0
      GUIDE.md
  2. +1
    -0
      README.md
  3. +6
    -0
      cmd/writeas/cli.go
  4. +13
    -0
      cmd/writeas/commands.go

+ 1
- 0
GUIDE.md Datei anzeigen

@@ -18,6 +18,7 @@ writeas [global options] command [command options] [arguments...]
COMMANDS:
post Alias for default action: create post from stdin
new Compose a new post from the command-line and publish
publish Publish a file to Write.as
delete Delete a post
update Update (overwrite) a post
get Read a raw post


+ 1
- 0
README.md Datei anzeigen

@@ -58,6 +58,7 @@ writeas [global options] command [command options] [arguments...]
COMMANDS:
post Alias for default action: create post from stdin
new Compose a new post from the command-line and publish
publish Publish a file to Write.as
delete Delete a post
update Update (overwrite) a post
get Read a raw post


+ 6
- 0
cmd/writeas/cli.go Datei anzeigen

@@ -116,6 +116,12 @@ func main() {
Flags: postFlags,
},
{
Name: "publish",
Usage: "Publish a file to Write.as",
Action: cmdPublish,
Flags: postFlags,
},
{
Name: "delete",
Usage: "Delete a post",
Action: cmdDelete,


+ 13
- 0
cmd/writeas/commands.go Datei anzeigen

@@ -4,6 +4,7 @@ import (
"fmt"
"github.com/howeyc/gopass"
"gopkg.in/urfave/cli.v1"
"io/ioutil"
"os"
)

@@ -44,6 +45,18 @@ func cmdNew(c *cli.Context) error {
return nil
}

func cmdPublish(c *cli.Context) error {
filename := c.Args().Get(0)
if filename == "" {
return cli.NewExitError("usage: writeas publish <filename>", 1)
}
content, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
return handlePost(content, c)
}

func cmdDelete(c *cli.Context) error {
friendlyID := c.Args().Get(0)
token := c.Args().Get(1)


Laden…
Abbrechen
Speichern