mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
fix dry run with options file
This commit is contained in:
parent
5838b5d6eb
commit
766aba2508
@ -1,6 +1,6 @@
|
||||
# Mark
|
||||
|
||||
Mark it's tool for syncing your markdown documentation with Atlassian
|
||||
Mark it's the tool for syncing your markdown documentation with Atlassian
|
||||
Confluence pages.
|
||||
|
||||
This is very usable if you store documentation to your orthodox software in git
|
||||
|
56
main.go
56
main.go
@ -78,6 +78,34 @@ func main() {
|
||||
optionsFile, shouldReadOptions = args["-c"].(string)
|
||||
)
|
||||
|
||||
config, err := getConfig(filepath.Join(os.Getenv("HOME"), ".config/mark"))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if shouldReadOptions {
|
||||
optionsConfig, err := getConfig(optionsFile)
|
||||
if err != nil {
|
||||
log.Fatalf("can't read options config '%s': %s", optionsFile, err)
|
||||
}
|
||||
|
||||
targetURL, err = optionsConfig.GetString("url")
|
||||
if err != nil {
|
||||
log.Fatal(
|
||||
"can't read `url` value from options file (%s): %s",
|
||||
optionsFile, err,
|
||||
)
|
||||
}
|
||||
|
||||
targetFile, err = optionsConfig.GetString("file")
|
||||
if err != nil {
|
||||
log.Fatal(
|
||||
"can't read `file` value from options file (%s): %s",
|
||||
optionsFile, err,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
markdownData, err := ioutil.ReadFile(targetFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -90,11 +118,6 @@ func main() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
config, err := getConfig(filepath.Join(os.Getenv("HOME"), ".config/mark"))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if username == "" {
|
||||
username, err = config.GetString("username")
|
||||
if err != nil {
|
||||
@ -123,29 +146,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if shouldReadOptions {
|
||||
optionsConfig, err := getConfig(optionsFile)
|
||||
if err != nil {
|
||||
log.Fatalf("can't read options config '%s': %s", optionsFile, err)
|
||||
}
|
||||
|
||||
targetURL, err = optionsConfig.GetString("url")
|
||||
if err != nil {
|
||||
log.Fatal(
|
||||
"can't read `url` value from options file (%s): %s",
|
||||
optionsFile, err,
|
||||
)
|
||||
}
|
||||
|
||||
targetFile, err = optionsConfig.GetString("file")
|
||||
if err != nil {
|
||||
log.Fatal(
|
||||
"can't read `file` value from options file (%s): %s",
|
||||
optionsFile, err,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
url, err := url.Parse(targetURL)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user