-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format bool arguments in a way it expected by kopia's cmd lib. #1849
Conversation
Thanks for submitting this pull request 🎉. The team will review it soon and get back to you. If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pkg/kopia/command/snapshot.go
Outdated
@@ -64,7 +64,7 @@ type SnapshotRestoreCommandArgs struct { | |||
func SnapshotRestore(cmdArgs SnapshotRestoreCommandArgs) []string { | |||
args := commonArgs(cmdArgs.CommandArgs, false) | |||
args = args.AppendLoggable(snapshotSubCommand, restoreSubCommand, cmdArgs.SnapID, cmdArgs.TargetPath) | |||
args = args.AppendLoggableKV(ignorePermissionsError, strconv.FormatBool(cmdArgs.IgnorePermissionErrors)) | |||
args = args.AppendLoggableBool(ignorePermissionsError, cmdArgs.IgnorePermissionErrors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimonOmsk Wouldn't it be simpler if we do
if cmdArgs.IgnorePermissionErrors {
args = args.AppendLoggable(ignorePermissionsError)
} else {
args = args.AppendLoggable(noIgnorePermissionsError)
}
noIgnorePermissionsError
is a constant with --no-ignore-permission-errors
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's simpler, but we'd have to introduce 2 arguments for every single argument. I think it's up to you here. If you think it's easier I would do it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like @pavannd1's proposal. It's simple and straightforward.
Change Overview
Kopia uses Kingpin(https://github.com/alecthomas/kingpin) lib for handling cmd args.
This lib does not allow to set bool var in k=v way. Instead it uses k\no-k format.
It means that instead of --ingore-permission-errors=false we should use --no-ignore-permission-errors argument.
From https://github.com/alecthomas/kingpin/blob/master/README.md#boolean-values
Pull request type
Please check the type of change your PR introduces:
Test Plan