Skip to content

Commit

Permalink
Merge branch version/0-43-0-RC1 to adopt changes from PR #2942
Browse files Browse the repository at this point in the history
  • Loading branch information
as-builds committed Dec 13, 2023
2 parents db6ce57 + 098d4a4 commit 174c6eb
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
22 changes: 21 additions & 1 deletion cmd/state-installer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Params struct {
isUpdate bool
activate *project.Namespaced
activateDefault *project.Namespaced
showVersion bool
}

func newParams() *Params {
Expand Down Expand Up @@ -184,11 +185,16 @@ func main() {
Hidden: true, // Since we already expose the path as an argument, let's not confuse the user
Value: &params.path,
},
{
Name: "version",
Shorthand: "v",
Value: &params.showVersion,
},
// The remaining flags are for backwards compatibility (ie. we don't want to error out when they're provided)
{Name: "nnn", Shorthand: "n", Hidden: true, Value: &garbageBool}, // don't prompt; useless cause we don't prompt anyway
{Name: "channel", Hidden: true, Value: &garbageString},
{Name: "bbb", Shorthand: "b", Hidden: true, Value: &garbageString},
{Name: "vvv", Shorthand: "v", Hidden: true, Value: &garbageString},
{Name: "vvv", Hidden: true, Value: &garbageString},
{Name: "source-path", Hidden: true, Value: &garbageString},
},
[]*captain.Argument{
Expand Down Expand Up @@ -226,6 +232,20 @@ func main() {
}

func execute(out output.Outputer, cfg *config.Instance, an analytics.Dispatcher, args []string, params *Params) error {
if params.showVersion {
vd := installation.VersionData{
"CLI Installer",
constants.LibraryLicense,
constants.Version,
constants.BranchName,
constants.RevisionHash,
constants.Date,
constants.OnCI == "true",
}
out.Print(locale.T("version_info", vd))
return nil
}

an.Event(anaConst.CatInstallerFunnel, "exec")

if params.path == "" {
Expand Down
28 changes: 27 additions & 1 deletion cmd/state-svc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/events"
"github.com/ActiveState/cli/internal/installation"
"github.com/ActiveState/cli/internal/ipc"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/logging"
Expand Down Expand Up @@ -114,9 +115,34 @@ func run(cfg *config.Instance) error {

p := primer.New(nil, out, nil, nil, nil, nil, cfg, nil, nil, an)

showVersion := false
cmd := captain.NewCommand(
path.Base(os.Args[0]), "", "", p, nil, nil,
path.Base(os.Args[0]),
"",
"",
p,
[]*captain.Flag{
{
Name: "version",
Shorthand: "v",
Value: &showVersion,
},
},
nil,
func(ccmd *captain.Command, args []string) error {
if showVersion {
vd := installation.VersionData{
"CLI Service",
constants.LibraryLicense,
constants.Version,
constants.BranchName,
constants.RevisionHash,
constants.Date,
constants.OnCI == "true",
}
out.Print(locale.T("version_info", vd))
return nil
}
out.Print(ccmd.UsageText())
return nil
},
Expand Down
1 change: 1 addition & 0 deletions internal/installation/versiondata.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package installation

type VersionData struct {
Name string `json:"name"`
License string `json:"license"`
Version string `json:"version"`
Branch string `json:"branch"`
Expand Down
2 changes: 1 addition & 1 deletion internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ confirm_update_unlocked_version_prompt:
other: "Are you sure you want to unlock the State Tool version from your project?"
version_info:
other: |
ActiveState CLI by ActiveState Software Inc.
ActiveState {{.Name}} by ActiveState Software Inc.
License [NOTICE]{{.License}}[/RESET]
Version [NOTICE]{{.Version}}[/RESET]
Revision [NOTICE]{{.Revision}}[/RESET]
Expand Down
1 change: 1 addition & 0 deletions internal/runners/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func (s *State) Run(usageFunc func() error) error {
if s.opts.Version {
checker.RunUpdateNotifier(s.an, s.svcMdl, s.out)
vd := installation.VersionData{
"CLI",
constants.LibraryLicense,
constants.Version,
constants.BranchName,
Expand Down

0 comments on commit 174c6eb

Please sign in to comment.