Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Cobra #37

Merged
merged 25 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58a2922
Create `cobra/`
slashtechno Jun 17, 2024
9c4f397
Add publish command to cross-blogger
slashtechno Jun 17, 2024
64355d4
feat: Allow for multiple destinations and attributes
slashtechno Jun 18, 2024
d08777f
feat: Add `--config`
slashtechno Jun 18, 2024
ba5478f
Add debugging configuration
slashtechno Jun 18, 2024
768df2b
Work on creating a config file with default values
slashtechno Jun 18, 2024
3fe45b2
feat: Create default toml config
slashtechno Jun 18, 2024
907048d
Work on adding structs for destinations
slashtechno Jun 18, 2024
58da0d7
fix: make config keys lowercase
slashtechno Jun 18, 2024
7066d7f
refactor!: Move destinations to `cmd/destinations.go`
slashtechno Jun 18, 2024
e20089e
feat: change destinations to platforms and prepare to use OAuth2.0
slashtechno Jun 18, 2024
72db56f
continue to work on OAuth
slashtechno Jun 18, 2024
7e270a0
feat: Got OAuth working!
slashtechno Jun 18, 2024
aec7f58
feat: get the Blogger blog ID
slashtechno Jun 18, 2024
f222c2b
feat: Add JS to close OAuth tab after token retrieval
slashtechno Jun 18, 2024
37f3911
feat: Continued to add logic for setting sources and destinations
slashtechno Jun 18, 2024
3a24eda
feat: store the refresh token so the OAuth flow isn't required
slashtechno Jun 19, 2024
66ded0e
feat: Add support for pulling Blogger post data
slashtechno Jun 19, 2024
0792fb1
feat: Implement posting to Markdown
slashtechno Jun 19, 2024
e8fe17a
fix: Marshal YAML before writing it
slashtechno Jun 19, 2024
55a49ce
feat: Add overwrite option for Markdown
slashtechno Jun 19, 2024
11ab121
refactor: add prepareBlogger function to improve readability
slashtechno Jun 19, 2024
277c5a6
feat: add support for publishing to Blogger
slashtechno Jun 19, 2024
d8c8579
feat!: Publish from Markdown
slashtechno Jun 19, 2024
feb34e4
feat!: Complete migration to Cobra
slashtechno Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test*
output.*
.env*
config.toml
*_markdown/
.env
52 changes: 52 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "--help for publish",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["publish", "--help"],
"console": "integratedTerminal"
},
{
"name": "Publish from blogger",
"type": "go",
"request": "launch",
"program": "${workspaceFolder}",
// https://www.blogger.com/edit-profile.g
"args": ["publish", "blogger", "${input:PostURL}", "${input:Destination}"],
// "envFile": "${workspaceFolder}/.env",
"console": "integratedTerminal"
},
{
"name": "Publish from Markdown",
"type": "go",
"request": "launch",
"program": "${workspaceFolder}",
"args": ["publish", "markdown", "${input:MarkdownPath}", "${input:Destination}"],
"console": "integratedTerminal"
}
],
"inputs": [
{
"id": "PostURL",
"type": "promptString",
"description": "Enter the URL of the Blogger post to publish",
"default": "https://itsfrommars.blogspot.com/2024/06/hello-world_11.html"
},
{
"id": "MarkdownPath",
"type": "promptString",
"description": "Enter the path of the Markdown file to publish",
"default": "hello-world.md"
},
{
"id": "Destination",
"type": "promptString",
"description": "Enter the destination to publish",
"default": "markdown"
}
]
}
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.

Loading
Loading