@@ -91,7 +91,7 @@ dev My Dev Log | |||
#### List posts | |||
This lists all posts you've published from your device | |||
This lists all anonymous posts you've published. If authenticated, it will include posts on your account as well as any local / unclaimed posts. | |||
Pass the `--url` flag to show the list with full post URLs, and the `--md` flag to return URLs with Markdown enabled. | |||
@@ -4,8 +4,6 @@ writeas-cli | |||
Command line interface for [Write.as](https://write.as). Works on Windows, macOS, and Linux. | |||
**NOTE: the `master` branch is currently unstable while we prepare the v2.0 release! You should install via official release channel, or build from the `v1.2` tag.** | |||
## Features | |||
* Publish anonymously to Write.as | |||
@@ -26,10 +24,10 @@ The easiest way to get the CLI is to download a pre-built executable for your OS | |||
Get the latest version for your operating system as a standalone executable. | |||
**Windows**<br /> | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v1.2/writeas_1.2_windows_amd64.zip) or [32-bit](https://github.com/writeas/writeas-cli/releases/download/v1.2/writeas_1.2_windows_386.zip) executable and put it somewhere in your `%PATH%`. | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v2.0.0/writeas_2.0.0_windows_amd64.zip) or [32-bit](https://github.com/writeas/writeas-cli/releases/download/v2.0.0/writeas_2.0.0_windows_386.zip) executable and put it somewhere in your `%PATH%`. | |||
**macOS**<br /> | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v1.2/writeas_1.2_darwin_amd64.tar.gz) executable and put it somewhere in your `$PATH`, like `/usr/local/bin`. | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v2.0.0/writeas_2.0.0_darwin_amd64.zip) executable and put it somewhere in your `$PATH`, like `/usr/local/bin`. | |||
**Debian-based Linux**<br /> | |||
```bash | |||
@@ -39,7 +37,7 @@ sudo apt-get update && sudo apt-get install writeas-cli | |||
``` | |||
**Linux (other)**<br /> | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v1.2/writeas_1.2_linux_amd64.tar.gz) or [32-bit](https://github.com/writeas/writeas-cli/releases/download/v1.2/writeas_1.2_linux_386.tar.gz) executable and put it somewhere in your `$PATH`, like `/usr/local/bin`. | |||
Download the [64-bit](https://github.com/writeas/writeas-cli/releases/download/v2.0.0/writeas_2.0.0_linux_amd64.tar.gz) or [32-bit](https://github.com/writeas/writeas-cli/releases/download/v2.0.0/writeas_2.0.0_linux_386.tar.gz) executable and put it somewhere in your `$PATH`, like `/usr/local/bin`. | |||
### Go get it | |||
```bash | |||
@@ -70,7 +70,7 @@ func DoFetch(c *cli.Context, friendlyID string) error { | |||
func DoFetchPosts(c *cli.Context) ([]writeas.Post, error) { | |||
cl, err := newClient(c, true) | |||
if err != nil { | |||
return nil, fmt.Errorf("Unable to create client: %v", err) | |||
return nil, fmt.Errorf("%v", err) | |||
} | |||
posts, err := cl.GetUserPosts() | |||
@@ -86,7 +86,7 @@ func DoFetchPosts(c *cli.Context) ([]writeas.Post, error) { | |||
func DoPost(c *cli.Context, post []byte, font string, encrypt, code bool) (*writeas.Post, error) { | |||
cl, err := newClient(c, false) | |||
if err != nil { | |||
return nil, fmt.Errorf("Unable to create client: %v", err) | |||
return nil, fmt.Errorf("%v", err) | |||
} | |||
pp := &writeas.PostParams{ | |||
@@ -184,7 +184,7 @@ func DoFetchCollections(c *cli.Context) ([]RemoteColl, error) { | |||
func DoUpdate(c *cli.Context, post []byte, friendlyID, token, font string, code bool) error { | |||
cl, err := newClient(c, false) | |||
if err != nil { | |||
return fmt.Errorf("Unable to create client: %v", err) | |||
return fmt.Errorf("%v", err) | |||
} | |||
params := writeas.PostParams{} | |||
@@ -210,7 +210,7 @@ func DoUpdate(c *cli.Context, post []byte, friendlyID, token, font string, code | |||
func DoDelete(c *cli.Context, friendlyID, token string) error { | |||
cl, err := newClient(c, false) | |||
if err != nil { | |||
return fmt.Errorf("Unable to create client: %v", err) | |||
return fmt.Errorf("%v", err) | |||
} | |||
err = cl.DeletePost(friendlyID, token) | |||
@@ -229,7 +229,7 @@ func DoDelete(c *cli.Context, friendlyID, token string) error { | |||
func DoLogIn(c *cli.Context, username, password string) error { | |||
cl, err := newClient(c, false) | |||
if err != nil { | |||
return fmt.Errorf("Unable to create client: %v", err) | |||
return fmt.Errorf("%v", err) | |||
} | |||
u, err := cl.LogIn(username, password) | |||
@@ -251,7 +251,7 @@ func DoLogIn(c *cli.Context, username, password string) error { | |||
func DoLogOut(c *cli.Context) error { | |||
cl, err := newClient(c, true) | |||
if err != nil { | |||
return fmt.Errorf("Unable to create client: %v", err) | |||
return fmt.Errorf("%v", err) | |||
} | |||
err = cl.LogOut() | |||
@@ -120,7 +120,7 @@ func GetPosts(c *cli.Context) *[]Post { | |||
return &posts | |||
} | |||
func GetUserPosts(c *cli.Context) ([]RemotePost, error) { | |||
func GetUserPosts(c *cli.Context, draftsOnly bool) ([]RemotePost, error) { | |||
waposts, err := DoFetchPosts(c) | |||
if err != nil { | |||
return nil, err | |||
@@ -132,6 +132,9 @@ func GetUserPosts(c *cli.Context) ([]RemotePost, error) { | |||
posts := []RemotePost{} | |||
for _, p := range waposts { | |||
if draftsOnly && p.Collection != nil { | |||
continue | |||
} | |||
post := RemotePost{ | |||
Post: Post{ | |||
ID: p.ID, | |||
@@ -168,6 +168,10 @@ func main() { | |||
Usage: "Use with --url to return URLs with Markdown enabled", | |||
}, | |||
cli.BoolFlag{ | |||
Name: "tor, t", | |||
Usage: "Get posts via Tor hidden service, if authenticated", | |||
}, | |||
cli.BoolFlag{ | |||
Name: "url", | |||
Usage: "Show list with URLs", | |||
}, | |||
@@ -113,7 +113,7 @@ func CmdDelete(c *cli.Context) error { | |||
err := api.DoDelete(c, friendlyID, token) | |||
if err != nil { | |||
return cli.NewExitError(fmt.Sprintf("Couldn't delete remote copy: %v", err), 1) | |||
return cli.NewExitError(fmt.Sprintf("Couldn't delete post: %v", err), 1) | |||
} | |||
// TODO: Delete local file, if necessary | |||
@@ -192,6 +192,42 @@ func CmdListPosts(c *cli.Context) error { | |||
posts := api.GetPosts(c) | |||
u, _ := config.LoadUser(config.UserDataDir(c.App.ExtraInfo()["configDir"])) | |||
if u != nil { | |||
if config.IsTor(c) { | |||
log.Info(c, "Getting posts via hidden service...") | |||
} else { | |||
log.Info(c, "Getting posts...") | |||
} | |||
remotePosts, err := api.GetUserPosts(c, true) | |||
if err != nil { | |||
return cli.NewExitError(fmt.Sprintf("error getting posts: %v", err), 1) | |||
} | |||
if len(remotePosts) > 0 { | |||
fmt.Println("Anonymous Posts") | |||
if details { | |||
identifier := "URL" | |||
if ids || !urls { | |||
identifier = "ID" | |||
} | |||
fmt.Println(identifier) | |||
} | |||
} | |||
for _, p := range remotePosts { | |||
identifier := getPostURL(c, p.ID) | |||
if ids || !urls { | |||
identifier = p.ID | |||
} | |||
fmt.Println(identifier) | |||
} | |||
if len(*posts) > 0 { | |||
fmt.Printf("\nUnclaimed Posts\n") | |||
} | |||
} | |||
if details { | |||
var p api.Post | |||
tw := tabwriter.NewWriter(os.Stdout, 10, 0, 2, ' ', tabwriter.TabIndent) | |||
@@ -14,7 +14,7 @@ require ( | |||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect | |||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect | |||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect | |||
github.com/writeas/go-writeas/v2 v2.0.0 | |||
github.com/writeas/go-writeas/v2 v2.0.2 | |||
github.com/writeas/saturday v0.0.0-20170402010311-f455b05c043f // indirect | |||
github.com/writeas/web-core v0.0.0-20181111165528-05f387ffa1b3 | |||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 // indirect | |||
@@ -33,10 +33,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykE | |||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= | |||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w= | |||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= | |||
github.com/writeas/go-writeas/v2 v2.0.0 h1:KjDI5bQSAIH0IzkKW3uGoY98I1A4DrBsSqBklgyOvHw= | |||
github.com/writeas/go-writeas/v2 v2.0.0/go.mod h1:9sjczQJKmru925fLzg0usrU1R1tE4vBmQtGnItUMR0M= | |||
github.com/writeas/go-writeas/v2 v2.0.1 h1:2ptcSFARmmiQh6/3Bj3dAMAvSPgntf+k2IJwV9CxpSU= | |||
github.com/writeas/go-writeas/v2 v2.0.1/go.mod h1:9sjczQJKmru925fLzg0usrU1R1tE4vBmQtGnItUMR0M= | |||
github.com/writeas/go-writeas/v2 v2.0.2 h1:akvdMg89U5oBJiCkBwOXljVLTqP354uN6qnG2oOMrbk= | |||
github.com/writeas/go-writeas/v2 v2.0.2/go.mod h1:9sjczQJKmru925fLzg0usrU1R1tE4vBmQtGnItUMR0M= | |||
github.com/writeas/impart v0.0.0-20180808220913-fef51864677b h1:vsZIsYneuNwXMsnh0lKviEVc8WeIqBG4RTmGWU86HpI= | |||
github.com/writeas/impart v0.0.0-20180808220913-fef51864677b/go.mod h1:sUkQZZHJfrVNsoD4QbkrYrRSQtCN3SaUPWKdohmFKT8= | |||
github.com/writeas/impart v1.1.0 h1:nPnoO211VscNkp/gnzir5UwCDEvdHThL5uELU60NFSE= | |||