Skip to content

Commit

Permalink
feat!: Complete migration to Cobra
Browse files Browse the repository at this point in the history
docs: update README for use with Cobra
  • Loading branch information
slashtechno authored Jun 19, 2024
1 parent d8c8579 commit feb34e4
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 553 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
test*
output.*
.env*
config.json
_debug*
config.toml
*_markdown/
.env
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cobra",
"program": "${workspaceFolder}",
"args": ["publish", "--help"],
"console": "integratedTerminal"
},
{
"name": "Publish from blogger",
"type": "go",
"request": "launch",
"program": "${workspaceFolder}/cobra",
"program": "${workspaceFolder}",
// https://www.blogger.com/edit-profile.g
"args": ["publish", "blogger", "${input:PostURL}", "${input:Destination}"],
// "envFile": "${workspaceFolder}/cobra/.env",
// "envFile": "${workspaceFolder}/.env",
"console": "integratedTerminal"
},
{
"name": "Publish from Markdown",
"type": "go",
"request": "launch",
"program": "${workspaceFolder}/cobra",
"program": "${workspaceFolder}",
"args": ["publish", "markdown", "${input:MarkdownPath}", "${input:Destination}"],
"console": "integratedTerminal"
}
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cross-blogger
Cross-service (and cross-platform) blog posting utility
Soon-to-be headless CMS for static site generators powered by Google's Blogger.

### Installation
#### Compiled Binaries
Expand All @@ -11,25 +11,28 @@ Using `go install`, you can compile and add the program to the PATH.
Either run `go install github.com/slashtechno/cross-blogger@latest`, follow the same process as compiling the program locally, but replace `go build` with `go install`.

### Usage
To use this program, just run the executable in the terminal.
Sources and destinations should first be configured in the `config.yaml` file.
For Google OAuth, the `--client-id` and `--client-secret` flags are required but can be set as environment variables (`CROSS_BLOGGER_GOOGLE_CLIENT_ID`/`CROSS_BLOGGER_GOOGLE_CLIENT_SECRET`). However these can also be set in the `config.yaml` file, passed as environment variables, or put in a `.env` file. When a refresh token is not provided, the program will commence the OAuth flow. This will write the refresh token, along with any other configuration, to the `config.yaml` file. If you prefer to use other methods to pass the credentials, you can remove the lines and use the other methods.
#### Help Output
From `cross-blogger --help`
From `cross-blogger publish --help`
```text
Usage: cross-blogger.exe --client-id CLIENT-ID --client-secret CLIENT-SECRET [--refresh-token REFRESH-TOKEN] [--log-level LOG-LEVEL] [--log-color] <command> [<args>]
Options:
--client-id CLIENT-ID
Google OAuth client ID [env: CLIENT_ID]
--client-secret CLIENT-SECRET
Google OAuth client secret [env: CLIENT_SECRET]
--refresh-token REFRESH-TOKEN
Google OAuth refresh token [env: REFRESH_TOKEN]
--log-level LOG-LEVEL
"debug", "info", "warning", "error", or "fatal" [default: info, env: LOG_LEVEL]
--log-color Force colored logs [default: false, env: LOG_COLOR]
--help, -h display this help and exit
Publish to a destination from a source.
Specify the source with the first positional argument.
The second positional argument is the specifier, such as a Blogger post URL or a file path.
All arguments after the first are treated as destinations.
Destinations should be the name of the destinations specified in the config file
Commands:
google-oauth Store Google OAuth refresh token
publish Publish to a destination
Usage:
cross-blogger publish [flags]
Flags:
-r, --dry-run Don't actually publish
--google-client-id string Google OAuth client ID
--google-client-secret string Google OAuth client secret
--google-refresh-token string Google OAuth refresh token
-h, --help help for publish
-t, --title string Specify custom title instead of using the default
Global Flags:
--config string config file path (default "config.toml")
```
40 changes: 0 additions & 40 deletions args.go

This file was deleted.

2 changes: 1 addition & 1 deletion cobra/cmd/platforms.go → cmd/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
md "github.com/JohannesKaufmann/html-to-markdown"
"github.com/charmbracelet/log"
"github.com/go-resty/resty/v2"
"github.com/slashtechno/cross-blogger/cobra/pkg/oauth"
"github.com/slashtechno/cross-blogger/pkg/oauth"
"github.com/spf13/afero"
"go.abhg.dev/goldmark/frontmatter"
)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions cobra/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions cobra/config.toml.example

This file was deleted.

71 changes: 0 additions & 71 deletions cobra/main.go

This file was deleted.

26 changes: 26 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# type is a required field that specifies the type of the source or destination.
# name is the name of the source or destination. It is used to refer to the source or destination when running the command.
# overwrite is a boolean field that specifies whether to overwrite the file/post if it already exists. This is done by removing old files/posts that have the same title.
# blog_url is the URL of the blog
# content_dir is the directory where the markdown files are located
[[destinations]]
blog_url = 'https://example.com'
name = 'blog'
overwrite = false
type = 'blogger'

[[destinations]]
content_dir = 'content'
name = 'otherblog'
overwrite = false
type = 'markdown'

[[sources]]
blog_url = 'https://example.com'
name = 'someblog'
type = 'blogger'

[[sources]]
content_dir = 'content'
name = 'aBlogInMarkdown'
type = 'markdown'
Loading

0 comments on commit feb34e4

Please sign in to comment.