Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nyarly committed Sep 8, 2023
2 parents ecd7689 + f0d7bfd commit f0aeb9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ GLOBAL OPTIONS:
--password value, -p value use specified token for updating Confluence page. Specify - as password to read password from stdin, or your Personal access token. Username is not mandatory if personal access token is provided. For more info please see: https://developer.atlassian.com/server/confluence/confluence-server-rest-api/#authentication. [$MARK_PASSWORD]
--target-url value, -l value edit specified Confluence page. If -l is not specified, file should contain metadata (see above). [$MARK_TARGET_URL]
--base-url value, -b value, --base_url value base URL for Confluence. Alternative option for base_url config field. [$MARK_BASE_URL]
--config value, -c value use the specified configuration file. (default: "~/.config/mark") [$MARK_CONFIG]
--config value, -c value use the specified configuration file. (default: System specific) [$MARK_CONFIG]
--ci run on CI mode. It won't fail if files are not found. (default: false) [$MARK_CI]
--space value use specified space key. If the space key is not specified, it must be set in the page metadata. [$MARK_SPACE]
--parents value A list containing the parents of the document separated by parents-delimiter (default: '/'). These will be preprended to the ones defined in the document itself. [$MARK_PARENTS]
Expand All @@ -772,7 +772,7 @@ GLOBAL OPTIONS:
```

You can store user credentials in the configuration file, which should be
located in ~/.config/mark (or specified via `-c --config <path>`) with the following format (TOML):
located in a system specific directory (or specified via `-c --config <path>`) with the following format (TOML):

```toml
username = "your-email"
Expand All @@ -785,6 +785,11 @@ drop-h1 = true

**NOTE**: Labels aren't supported when using `minor-edit`!

**NOTE**: The system specific locations are described in here:
https://pkg.go.dev/os#UserConfigDir.
Currently these are:
On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%. On Plan 9, it returns $home/lib.

# Tricks

## Continuous Integration
Expand Down
14 changes: 11 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var flags = []cli.Flag{
&cli.StringFlag{
Name: "config",
Aliases: []string{"c"},
Value: filepath.Join(os.Getenv("HOME"), ".config/mark"),
Value: configFilePath(),
Usage: "use the specified configuration file.",
TakesFile: true,
EnvVars: []string{"MARK_CONFIG"},
Expand Down Expand Up @@ -189,11 +189,11 @@ func main() {
return altsrc.NewTomlSourceFromFile(filePath)
} else {
// Fall back to default if config is unset and path exists
_, err := os.Stat(filepath.Join(os.Getenv("HOME"), ".config/mark"))
_, err := os.Stat(configFilePath())
if os.IsNotExist(err) {
return &altsrc.MapInputSource{}, nil
}
return altsrc.NewTomlSourceFromFile(filepath.Join(os.Getenv("HOME"), ".config/mark"))
return altsrc.NewTomlSourceFromFile(configFilePath())
}
}),
EnableBashCompletion: true,
Expand Down Expand Up @@ -522,3 +522,11 @@ func processFile(

return target
}

func configFilePath() string {
fp, err := os.UserConfigDir()
if err != nil {
log.Fatal(err)
}
return filepath.Join(fp, "mark")
}

0 comments on commit f0aeb9b

Please sign in to comment.