2015-09-19 23:51:49 +06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2025-03-10 15:47:03 -06:00
|
|
|
"github.com/kovetskiy/mark/util"
|
2020-11-03 17:12:51 +03:00
|
|
|
"github.com/reconquest/pkg/log"
|
2023-04-18 15:06:16 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/urfave/cli/v2/altsrc"
|
2015-09-19 23:51:49 +06:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2025-04-13 00:23:10 +02:00
|
|
|
version = "12.2.0"
|
2023-04-18 15:06:16 +02:00
|
|
|
usage = "A tool for updating Atlassian Confluence pages from markdown."
|
2023-04-12 13:43:34 +02:00
|
|
|
description = `Mark is a tool to update Atlassian Confluence pages from markdown. Documentation is available here: https://github.com/kovetskiy/mark`
|
2015-09-19 23:51:49 +06:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-04-18 15:06:16 +02:00
|
|
|
app := &cli.App{
|
|
|
|
Name: "mark",
|
|
|
|
Usage: usage,
|
|
|
|
Description: description,
|
|
|
|
Version: version,
|
2025-03-11 11:31:16 -06:00
|
|
|
Flags: util.Flags,
|
|
|
|
Before: altsrc.InitInputSourceWithContext(util.Flags,
|
2023-04-18 15:06:16 +02:00
|
|
|
func(context *cli.Context) (altsrc.InputSourceContext, error) {
|
|
|
|
if context.IsSet("config") {
|
|
|
|
filePath := context.String("config")
|
|
|
|
return altsrc.NewTomlSourceFromFile(filePath)
|
|
|
|
} else {
|
2023-04-25 22:45:15 +02:00
|
|
|
// Fall back to default if config is unset and path exists
|
2025-03-10 15:47:03 -06:00
|
|
|
_, err := os.Stat(util.ConfigFilePath())
|
2023-04-25 22:45:15 +02:00
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return &altsrc.MapInputSource{}, nil
|
|
|
|
}
|
2025-03-10 15:47:03 -06:00
|
|
|
return altsrc.NewTomlSourceFromFile(util.ConfigFilePath())
|
2023-04-18 15:06:16 +02:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
EnableBashCompletion: true,
|
|
|
|
HideHelpCommand: true,
|
2025-03-10 15:47:03 -06:00
|
|
|
Action: util.RunMark,
|
2015-09-19 23:51:49 +06:00
|
|
|
}
|
|
|
|
|
2023-04-18 15:06:16 +02:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
2021-04-05 07:56:25 +03:00
|
|
|
log.Fatal(err)
|
2021-04-02 13:15:54 -04:00
|
|
|
}
|
2023-04-18 15:06:16 +02:00
|
|
|
}
|