Skip to content
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

Consistently use single quotes in actionable commands in user-facing messages. #2887

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/state-installer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D
case params.command != "":
an.Event(anaConst.CatInstallerFunnel, "forward-command")

out.Print(fmt.Sprintf("\nRunning `[ACTIONABLE]%s[/RESET]`\n", params.command))
out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]%s[/RESET]'\n", params.command))
cmd, args := exeutils.DecodeCmd(params.command)
if _, _, err := exeutils.ExecuteAndPipeStd(cmd, args, envSlice(binPath)); err != nil {
an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-command-err", err.Error())
Expand All @@ -391,7 +391,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D
case params.activate.IsValid():
an.Event(anaConst.CatInstallerFunnel, "forward-activate")

out.Print(fmt.Sprintf("\nRunning `[ACTIONABLE]state activate %s[/RESET]`\n", params.activate.String()))
out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]state activate %s[/RESET]'\n", params.activate.String()))
if _, _, err := exeutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activate.String()}, envSlice(binPath)); err != nil {
an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-activate-err", err.Error())
return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activate.String(), errs.JoinMessage(err)))
Expand All @@ -400,7 +400,7 @@ func postInstallEvents(out output.Outputer, cfg *config.Instance, an analytics.D
case params.activateDefault.IsValid():
an.Event(anaConst.CatInstallerFunnel, "forward-activate-default")

out.Print(fmt.Sprintf("\nRunning `[ACTIONABLE]state activate --default %s[/RESET]`\n", params.activateDefault.String()))
out.Print(fmt.Sprintf("\nRunning '[ACTIONABLE]state activate --default %s[/RESET]'\n", params.activateDefault.String()))
if _, _, err := exeutils.ExecuteAndPipeStd(stateExe, []string{"activate", params.activateDefault.String(), "--default"}, envSlice(binPath)); err != nil {
an.EventWithLabel(anaConst.CatInstallerFunnel, "forward-activate-default-err", err.Error())
return errs.Silence(errs.Wrap(err, "Could not activate %s, error returned: %s", params.activateDefault.String(), errs.JoinMessage(err)))
Expand Down
2 changes: 1 addition & 1 deletion cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (a *addCmdAs) deprecatedAlias(aliased *captain.Command, name string) {
func(c *captain.Command, args []string) error {
msg := locale.Tl(
"cmd_deprecated_notice",
"This command is deprecated. Please use `state {{.V0}}` instead.",
"This command is deprecated. Please use '[ACTIONABLE]state {{.V0}}[/RESET]' instead.",
aliased.Name(),
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/state/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func run(args []string, isInteractive bool, cfg *config.Instance, out output.Out
cmdName = childCmd.JoinedSubCommandNames() + " "
}
if !out.Type().IsStructured() {
err = errs.AddTips(err, locale.Tl("err_tip_run_help", "Run → [ACTIONABLE]`state {{.V0}}--help`[/RESET] for general help", cmdName))
err = errs.AddTips(err, locale.Tl("err_tip_run_help", "Run → '[ACTIONABLE]state {{.V0}}--help[/RESET]' for general help", cmdName))
}
errors.ReportError(err, cmds.Command(), an)
}
Expand Down
96 changes: 47 additions & 49 deletions internal/locale/locales/en-us.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/runbits/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *Repo) CloneProject(owner, name, path string, out output.Outputer, an an
err = locale.WrapError(err, "err_clone_repo", "Could not clone repository with URL: {{.V0}}, error received: {{.V1}}.", *project.RepoURL, err.Error())
tipMsg := locale.Tl(
"err_tip_git_ssh-add",
"If you are using an SSH key please ensure it's configured by running `[ACTIONABLE]ssh-add <path-to-key>[/RESET]`.",
"If you are using an SSH key please ensure it's configured by running '[ACTIONABLE]ssh-add <path-to-key>[/RESET]'.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This localization has the quotes before the tag whereas some others have it after the tag and around the command. Normally, I wouldn't be this nitpicky but since this PR is about consistency we should make sure they follow the same pattern. Additionally, is there any difference to the output where the quotes are placed? I assume not, but we should verify just to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I got confused reading my own ticket, thinking that single quotes either inside or outside the tags are okay (i.e. leave them be position-wise, just make sure they're single quotes).

However I agree that we should be consistent. The quotes should be outside the tags so that only the actionable text is highlighted. It makes it more clear what the user should type (no confusion on whether or not to type/include quotes, haha).

)
return errs.AddTips(err, tipMsg)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/runners/activate/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (r *Activate) Run(params *ActivateParams) (rerr error) {
} else {
r.out.Notice(locale.Tl(
"activate_default_optin_msg",
"To make this project always available for use without activating it in the future, run your activate command with the `[ACTIONABLE]--default[/RESET]` flag.",
"To make this project always available for use without activating it in the future, run your activate command with the '[ACTIONABLE]--default[/RESET]' flag.",
))
}
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func (r *Activate) Run(params *ActivateParams) (rerr error) {
return errs.Wrap(err, "Unable to get local commit")
}
if commitID == "" {
err := locale.NewInputError("err_project_no_commit", "Your project does not have a commit ID, please run `state push` first.", model.ProjectURL(proj.Owner(), proj.Name(), ""))
err := locale.NewInputError("err_project_no_commit", "Your project does not have a commit ID, please run [ACTIONIABLE]'state push'[/RESET] first.", model.ProjectURL(proj.Owner(), proj.Name(), ""))
return errs.AddTips(err, "Run → [ACTIONABLE]state push[/RESET] to create your project")
}

Expand Down
2 changes: 1 addition & 1 deletion internal/runners/auth/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewSignup(prime primeable) *Signup {

func (s *Signup) Run(params *SignupParams) error {
if s.Auth.Authenticated() {
return locale.NewInputError("err_auth_authenticated", "You are already authenticated as: {{.V0}}. You can log out by running `state auth logout`.", s.Auth.WhoAmI())
return locale.NewInputError("err_auth_authenticated", "You are already authenticated as: {{.V0}}. You can log out by running '[ACTIONABLE]state auth logout[/RESET]'.", s.Auth.WhoAmI())
}

return auth.SignupWithBrowser(s.Outputer, s.Auth, s.Prompter)
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/deploy/uninstall/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (u *Uninstall) Run(params *Params) error {
return locale.WrapInputError(
err,
"err_deploy_uninstall_cannot_get_cwd",
"Cannot determine current working directory. Please supply `--path` argument")
"Cannot determine current working directory. Please supply '[ACTIONABLE]--path[/RESET]' argument")
}
path = cwd
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/events/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewLog(prime primeable) *EventLog {
func (e *EventLog) Run(params *EventLogParams) error {
pid := process.ActivationPID(e.cfg)
if pid == -1 {
return locale.NewInputError("err_eventlog_pid", "Could not find parent process ID, make sure you're running this command from inside an activated state (run `state activate` first).")
return locale.NewInputError("err_eventlog_pid", "Could not find parent process ID, make sure you're running this command from inside an activated state (run '[ACTIONABLE]state activate[/RESET]' first).")
}

filepath := logging.FilePathFor(logging.FileNameFor(int(pid)))
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/export/privkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (p *PrivateKey) Run(params *PrivateKeyParams) error {

if !p.Auth.Authenticated() {
return locale.NewInputError("err_export_privkey_requires_auth",
"You need to be authenticated to run this command. Authenticate by running [ACTIONABLE]`state auth --prompt`[/RESET].")
"You need to be authenticated to run this command. Authenticate by running '[ACTIONABLE]state auth --prompt[/RESET]'.")
}

filepath := keypairs.LocalKeyFilename(p.cfg.ConfigPath(), constants.KeypairLocalFileName)
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/hello/hello_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func rationalizeError(err *error) {
*err,
locale.Tl("hello_err_no_project", "Cannot say hello because you are not in a project directory."),
errs.SetTips(
locale.Tl("hello_suggest_checkout", "Try using [ACTIONABLE]`state checkout`[/RESET] first."),
locale.Tl("hello_suggest_checkout", "Try using '[ACTIONABLE]state checkout[/RESET]' first."),
),
)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/runners/invite/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (i *invite) Run(params *Params, args []string) error {
return locale.NewInputError("err_no_projectfile", "Must be in a project directory.")
}
if !i.auth.Authenticated() {
return locale.NewInputError("err_invite_not_logged_in", "You need to authenticate with [ACTIONABLE]`state auth`[/RESET] before you can invite new members.")
return locale.NewInputError("err_invite_not_logged_in", "You need to authenticate with '[ACTIONABLE]state auth[/RESET]' before you can invite new members.")
}

if len(args) > 1 {
Expand Down
4 changes: 2 additions & 2 deletions internal/runners/languages/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func (l *Languages) Run() error {
locale.WrapError(
err,
"err_languages_no_commitid",
"Your project runtime does not have a commit defined, you may need to run [ACTIONABLE]`state pull`[/RESET] first.",
"Your project runtime does not have a commit defined, you may need to run '[ACTIONABLE]state pull[/RESET]' first.",
),
locale.Tl(
"languages_no_commitid_help",
"Run → [ACTIONABLE]`state pull`[/RESET] to update your project",
"Run → '[ACTIONABLE]state pull[/RESET]' to update your project",
),
)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/runners/packages/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func whatsNextMessages(name string, versions []string) []string {
locale.Tl(
"install_latest_version",
"To install the latest version, run "+
"[ACTIONABLE]`state install {{.V0}}`[/RESET]",
"'[ACTIONABLE]state install {{.V0}}[/RESET]'",
name,
),
)
Expand All @@ -236,7 +236,7 @@ func whatsNextMessages(name string, versions []string) []string {
locale.Tl(
"install_specific_version",
"To install a specific version, run "+
"[ACTIONABLE]`state install {{.V0}}@{{.V1}}[/RESET]`",
"'[ACTIONABLE]state install {{.V0}}@{{.V1}}[/RESET]'",
name, version,
),
)
Expand All @@ -248,7 +248,7 @@ func whatsNextMessages(name string, versions []string) []string {
locale.Tl(
"show_specific_version",
"To view details for a specific version, run "+
"[ACTIONABLE]`state info {{.V0}}@{{.V1}}`[/RESET]",
"'[ACTIONABLE]state info {{.V0}}@{{.V1}}[/RESET]'",
name, version,
),
)
Expand Down
4 changes: 2 additions & 2 deletions internal/runners/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p *Pull) Run(params *PullParams) (rerr error) {
}

if p.project.BranchName() == "" {
return locale.NewError("err_pull_branch", "Your [NOTICE]activestate.yaml[/RESET] project field does not contain a branch. Please ensure you are using the latest version of the State Tool by running [ACTIONABLE]`state update`[/RESET] and then trying again.")
return locale.NewError("err_pull_branch", "Your [NOTICE]activestate.yaml[/RESET] project field does not contain a branch. Please ensure you are using the latest version of the State Tool by running '[ACTIONABLE]state update[/RESET]' and then trying again.")
}

// Determine the project to pull from
Expand Down Expand Up @@ -258,7 +258,7 @@ func (p *Pull) mergeBuildScript(strategies *mono_models.MergeStrategies, remoteC
}
return locale.NewInputError(
"err_build_script_merge",
"Unable to automatically merge build scripts. Please resolve conflicts manually in '{{.V0}}' and then run [ACTIONABLE]`state commit`[/RESET]",
"Unable to automatically merge build scripts. Please resolve conflicts manually in '{{.V0}}' and then run '[ACTIONABLE]state commit[/RESET]'",
filepath.Join(p.project.Dir(), constants.BuildScriptFileName))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/runners/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s *Show) Run(params Params) error {

remoteProject, err := model.LegacyFetchProjectByName(owner, projectName)
if err != nil && errs.Matches(err, &model.ErrProjectNotFound{}) {
return locale.WrapError(err, "err_show_project_not_found", "Please run `state push` to synchronize this project with the ActiveState Platform.")
return locale.WrapError(err, "err_show_project_not_found", "Please run '[ACTIONABLE]state push[/RESET]' to synchronize this project with the ActiveState Platform.")
} else if err != nil {
return locale.WrapError(err, "err_show_get_project", "Could not get remote project details")
}
Expand Down
8 changes: 4 additions & 4 deletions internal/runners/tutorial/tutorial.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (t *Tutorial) RunNewProject(params NewProjectParams) error {

// Run state push
if err := runbits.Invoke(t.outputer, "push"); err != nil {
return locale.WrapInputError(err, "err_tutorial_state_push", "Could not push project to ActiveState Platform, try manually running `state push` from your project directory at {{.V0}}.", dir)
return locale.WrapInputError(err, "err_tutorial_state_push", "Could not push project to ActiveState Platform, try manually running '[ACTIONABLE]state push[/RESET]' from your project directory at {{.V0}}.", dir)
}

// Print outro
Expand Down Expand Up @@ -149,12 +149,12 @@ func (t *Tutorial) authFlow() error {
case signIn:
t.analytics.EventWithLabel(anaConsts.CatTutorial, "authentication-action", "sign-in")
if err := runbits.Invoke(t.outputer, "auth"); err != nil {
return locale.WrapInputError(err, "err_tutorial_signin", "Sign in failed. You could try manually signing in by running `state auth`.")
return locale.WrapInputError(err, "err_tutorial_signin", "Sign in failed. You could try manually signing in by running '[ACTIONABLE]state auth[/RESET]'.")
}
case signUpCLI:
t.analytics.EventWithLabel(anaConsts.CatTutorial, "authentication-action", "sign-up")
if err := runbits.Invoke(t.outputer, "auth", "signup"); err != nil {
return locale.WrapInputError(err, "err_tutorial_signup", "Sign up failed. You could try manually signing up by running `state auth signup`.")
return locale.WrapInputError(err, "err_tutorial_signup", "Sign up failed. You could try manually signing up by running '[ACTIONABLE]state auth signup[/RESET]'.")
}
case signUpBrowser:
t.analytics.EventWithLabel(anaConsts.CatTutorial, "authentication-action", "sign-up-browser")
Expand All @@ -164,7 +164,7 @@ func (t *Tutorial) authFlow() error {
}
t.outputer.Notice(locale.Tl("tutorial_signing_ready", "[NOTICE]Please sign in once you have finished signing up via your browser.[/RESET]"))
if err := runbits.Invoke(t.outputer, "auth"); err != nil {
return locale.WrapInputError(err, "err_tutorial_signin", "Sign in failed. You could try manually signing in by running `state auth`.")
return locale.WrapInputError(err, "err_tutorial_signin", "Sign in failed. You could try manually signing in by running '[ACTIONABLE]state auth[/RESET]'.")
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/platform/authentication/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ func (s *Auth) AuthenticateWithModel(credentials *mono_models.Credentials) error
if err != nil {
tips := []string{
locale.Tl("relog_tip", "If you're having trouble authenticating try logging out and logging back in again."),
locale.Tl("logout_tip", "Logout with [ACTIONABLE]`state auth logout`[/RESET]."),
locale.Tl("logout_tip", "Login with [ACTIONABLE]`state auth`[/RESET]."),
locale.Tl("logout_tip", "Logout with '[ACTIONABLE]state auth logout[/RESET]'."),
locale.Tl("logout_tip", "Login with '[ACTIONABLE]state auth[/RESET]'."),
}

switch err.(type) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/platform/model/cve.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func FetchProjectVulnerabilities(auth *authentication.Auth, org, project string)
if !auth.Authenticated() {
return nil, errs.AddTips(
locale.NewError("cve_needs_authentication", "You need to be authenticated in order to access vulnerability information about your project."),
locale.Tl("auth_tip", "Run `state auth` to authenticate."),
locale.T("auth_tip"),
)
}
req := request.VulnerabilitiesByProject(org, project)
Expand All @@ -48,7 +48,7 @@ func FetchCommitVulnerabilities(auth *authentication.Auth, commitID string) (*mo
if !auth.Authenticated() {
return nil, errs.AddTips(
locale.NewError("cve_needs_authentication", "You need to be authenticated in order to access vulnerability information about your project."),
locale.Tl("auth_tip", "Run `state auth` to authenticate."),
locale.T("auth_tip"),
)
}
req := request.VulnerabilitiesByCommit(commitID)
Expand Down
Loading