mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-12-22 08:16:25 +00:00
chore(lockfile) change flag to --lockfile
This is more consistent with the `lockfile` config option
This commit is contained in:
parent
de0862a3dd
commit
59b2393127
@ -41,7 +41,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().BoolVarP(&flags.VERBOSE, "verbose", "v", false, "verbose mode")
|
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.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.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)
|
cobra.OnInitialize(initConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
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.
|
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
|
```bash
|
||||||
autorestic --lockfile-path /path/to/my/.autorestic.lock.yml
|
autorestic --lockfile /path/to/my/.autorestic.lock.yml
|
||||||
```
|
```
|
||||||
|
@ -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:
|
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
|
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.
|
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.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package flags
|
package flags
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CI bool = false
|
CI bool = false
|
||||||
VERBOSE bool = false
|
VERBOSE bool = false
|
||||||
CRON_LEAN bool = false
|
CRON_LEAN bool = false
|
||||||
RESTIC_BIN string
|
RESTIC_BIN string
|
||||||
DOCKER_IMAGE string
|
DOCKER_IMAGE string
|
||||||
LOCKFILE_PATH string
|
LOCKFILE string
|
||||||
)
|
)
|
||||||
|
@ -20,14 +20,14 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// getLockfilePath returns the path to the lockfile. The path for the lockfile
|
// 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
|
// can be sources from multiple places If flags.LOCKFILE is set, its value is
|
||||||
// is used; if the config has the `lockfile` option set, its value is used;
|
// used; if the config has the `lockfile` option set, its value is used;
|
||||||
// otherwise the path is generated relative to the config file.
|
// otherwise the path is generated relative to the config file.
|
||||||
func getLockfilePath() string {
|
func getLockfilePath() string {
|
||||||
if flags.LOCKFILE_PATH != "" {
|
if flags.LOCKFILE != "" {
|
||||||
abs, err := filepath.Abs(flags.LOCKFILE_PATH)
|
abs, err := filepath.Abs(flags.LOCKFILE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return flags.LOCKFILE_PATH
|
return flags.LOCKFILE
|
||||||
}
|
}
|
||||||
return abs
|
return abs
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func setup(t *testing.T) {
|
func setup(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
cleanup := func() {
|
cleanup := func() {
|
||||||
flags.LOCKFILE_PATH = ""
|
flags.LOCKFILE = ""
|
||||||
config = nil
|
config = nil
|
||||||
once = sync.Once{}
|
once = sync.Once{}
|
||||||
viper.Reset()
|
viper.Reset()
|
||||||
@ -62,7 +62,7 @@ func TestGetLockfilePath(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
t.Run(testCase.name, func(t *testing.T) {
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
setup(t)
|
setup(t)
|
||||||
flags.LOCKFILE_PATH = testCase.flag
|
flags.LOCKFILE = testCase.flag
|
||||||
if testCase.config != "" {
|
if testCase.config != "" {
|
||||||
viper.Set("lockfile", testCase.config)
|
viper.Set("lockfile", testCase.config)
|
||||||
err := viper.WriteConfig()
|
err := viper.WriteConfig()
|
||||||
|
Loading…
Reference in New Issue
Block a user