-
Notifications
You must be signed in to change notification settings - Fork 109
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
feat: add support for saving public key to file using -output flag #318
Conversation
cmd/tesla-keygen/main.go
Outdated
@@ -90,7 +104,9 @@ func main() { | |||
config.RegisterCommandLineFlags() | |||
flag.Usage = cliUsage | |||
flag.BoolVar(&overwrite, "f", false, "Overwrite existing key if it exists") | |||
flag.StringVar(&outputFile, "output", "", "Path to save the public key") |
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.
The output of tesla-keygen --help
becomes:
-keyring-type type
Keyring type (file|keychain|pass). Defaults to $TESLA_KEYRING_TYPE.
-output string
Path to save the public key
-session-cache file
Load session info cache from file. Defaults to $TESLA_CACHE_FILE.
To make the argument of -outupt
"file" rather than "string", which is more consistent with the other options, please change the help string to:
Save public key to `file`. Defaults to stdout.
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.
Suggestion applied
|
||
// If outputFile is provided, write to file, else write to stdout | ||
var out io.Writer = os.Stdout | ||
if outputFile != "" { |
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.
Currently usageText
says:
The program writes the public key to stdout (except when deleting a key)
Please change to
The program writes the public key to stdout (except when deleting a key or setting the output location with -output)
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.
Suggestion applied
- Introduced the `-output` flag to allow users to specify a file path for saving the public key. - Updated the `printPublicKey` function to write the public key to the specified file, or to stdout if no file is provided. - Modified the `create` and `migrate` cases to support the `-output` flag when printing the public key. - Ensured backward compatibility by retaining stdout output when `-output` is not used.
3896bb1
to
b3a206f
Compare
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.
Thanks!
Description
-output
flag to allow users to specify a file path for saving the public key.printPublicKey
function to write the public key to the specified file, or to stdout if no file is provided.create
andmigrate
cases to support the-output
flag when printing the public key.-output
is not used.Fixes # (issue)
Type of change
Please select all options that apply to this change:
Checklist:
Confirm you have completed the following steps: