-
Notifications
You must be signed in to change notification settings - Fork 345
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(confirm): add --show-output
#427
base: main
Are you sure you want to change the base?
Conversation
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 have added some suggestions to help fix your linting error.
Also, you can check if it passes linting before pushing by using golangci-lint run
confirm/command.go
Outdated
} else { | ||
os.Exit(1) | ||
if o.ShowOutput { | ||
confirmationText := m.(model).negative | ||
if m.(model).confirmation { | ||
confirmationText = m.(model).affirmative | ||
} | ||
fmt.Println(m.(model).prompt, confirmationText) | ||
} | ||
|
||
if m.(model).confirmation { | ||
os.Exit(0) | ||
} else { | ||
os.Exit(1) | ||
} | ||
} |
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.
Here you should remove the else and outdent the code and also the last else statement can be outdented as well.
The code will look something like this.
}
if o.ShowOutput {
confirmationText := m.(model).negative
if m.(model).confirmation {
confirmationText = m.(model).affirmative
}
fmt.Println(m.(model).prompt, confirmationText)
}
if m.(model).confirmation {
os.Exit(0)
}
os.Exit(1)
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 must have missed the CI result notifications, really sorry.
This should be fixed as per you suggestions, thanks!
Regarding the model structure, do you think this commit is necessary?
Fixes nothing, this is a feature I found missing from a specific use case I had in mind.
Changes
Adds the
--show-output
flag togum confirm
which prints the prompt and the chosen action to STDOUT.This merge adds 2 commits, only the first one (
4f9235b
) is required for the feature to work.Since the feature doesn't affect
confirm/confirm.go
I feel like the second (432182f
) isn't necessary, but I still included it in case I misunderstood the purpose of the model structure.