diff --git a/cmd/root.go b/cmd/root.go index 4db353e..86b7714 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -41,7 +41,7 @@ func init() { rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode") rootCmd.PersistentFlags().StringVar(&flags.RESTIC_BIN, "restic-bin", "restic", "specify custom restic binary") rootCmd.PersistentFlags().StringVar(&flags.DOCKER_IMAGE, "docker-image", "cupcakearmy/autorestic:"+internal.VERSION, "specify a custom docker image") - rootCmd.PersistentFlags().StringVar(&flags.LOCKFILE_PATH, "lockfile-path", "", "specify a custom path for the lockfile (defaults to .autorestic.lock.yml next to the loaded autorestic config file)") + rootCmd.PersistentFlags().StringVar(&flags.LOCKFILE, "lockfile", "", "specify a custom path for the lockfile (defaults to .autorestic.lock.yml next to the loaded autorestic config file)") cobra.OnInitialize(initConfig) } diff --git a/docs/pages/cli/general.md b/docs/pages/cli/general.md index e653c77..cd304c7 100644 --- a/docs/pages/cli/general.md +++ b/docs/pages/cli/general.md @@ -35,10 +35,10 @@ With `--restic-bin` you can specify to run a specific restic binary. This can be autorestic --restic-bin /some/path/to/my/custom/restic/binary ``` -## `--lockfile-path` +## `--lockfile` Specify the path for the [lockfile](../lockfile.md) used by `autorestic`. If omitted, this will default to `.autorestic.lock.yml` next to the loaded config file. ```bash -autorestic --lockfile-path /path/to/my/.autorestic.lock.yml +autorestic --lockfile /path/to/my/.autorestic.lock.yml ``` diff --git a/docs/pages/lockfile.md b/docs/pages/lockfile.md index ca111f0..11baaa3 100644 --- a/docs/pages/lockfile.md +++ b/docs/pages/lockfile.md @@ -8,7 +8,7 @@ By default, the lockfile is stored next to your [configuration file](./config.md The path to the lockfile can be customized if need be. This can be done is a few ways: -1. Using the `--lockfile-path ...` command line flag +1. Using the `--lockfile ...` command line flag 1. Setting `lockfile: ...` in the configuration file Note that `autorestic` will check for a customized lockfile path in the order listed above. This means that if you specify a lockfile path in multiple places, the method that's higher in the list will win. diff --git a/internal/flags/flags.go b/internal/flags/flags.go index 801aed7..73560e1 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -1,10 +1,10 @@ package flags var ( - CI bool = false - VERBOSE bool = false - CRON_LEAN bool = false - RESTIC_BIN string - DOCKER_IMAGE string - LOCKFILE_PATH string + CI bool = false + VERBOSE bool = false + CRON_LEAN bool = false + RESTIC_BIN string + DOCKER_IMAGE string + LOCKFILE string ) diff --git a/internal/lock.go b/internal/lock.go index a128bdf..38037cd 100644 --- a/internal/lock.go +++ b/internal/lock.go @@ -20,14 +20,14 @@ const ( ) // getLockfilePath returns the path to the lockfile. The path for the lockfile -// can be sources from multiple places If flags.LOCKFILE_PATH is set, its value -// is used; if the config has the `lockfile` option set, its value is used; +// can be sources from multiple places If flags.LOCKFILE is set, its value is +// used; if the config has the `lockfile` option set, its value is used; // otherwise the path is generated relative to the config file. func getLockfilePath() string { - if flags.LOCKFILE_PATH != "" { - abs, err := filepath.Abs(flags.LOCKFILE_PATH) + if flags.LOCKFILE != "" { + abs, err := filepath.Abs(flags.LOCKFILE) if err != nil { - return flags.LOCKFILE_PATH + return flags.LOCKFILE } return abs } diff --git a/internal/lock_test.go b/internal/lock_test.go index e364579..eb5a6a2 100644 --- a/internal/lock_test.go +++ b/internal/lock_test.go @@ -17,7 +17,7 @@ import ( func setup(t *testing.T) { t.Helper() cleanup := func() { - flags.LOCKFILE_PATH = "" + flags.LOCKFILE = "" config = nil once = sync.Once{} viper.Reset() @@ -62,7 +62,7 @@ func TestGetLockfilePath(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { setup(t) - flags.LOCKFILE_PATH = testCase.flag + flags.LOCKFILE = testCase.flag if testCase.config != "" { viper.Set("lockfile", testCase.config) err := viper.WriteConfig()