Skip to content

Commit

Permalink
Revert "Merge pull request #2903 from ActiveState/mitchell/dx-2334"
Browse files Browse the repository at this point in the history
This reverts commit 85224ba, reversing
changes made to a99f200.
  • Loading branch information
mitchell-as committed Dec 14, 2023
1 parent 85224ba commit 98c0cde
Show file tree
Hide file tree
Showing 584 changed files with 3,125 additions and 3,878 deletions.
4 changes: 2 additions & 2 deletions cmd/state/internal/cmdtree/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newBundleUninstallCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("bundle_arg_name"),
Description: locale.T("bundle_arg_name_description"),
Value: &params.Package,
Value: &params.Name,
Required: true,
},
},
Expand Down Expand Up @@ -118,7 +118,7 @@ func newBundlesSearchCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("bundle_arg_name"),
Description: locale.T("bundle_arg_name_description"),
Value: &params.Ingredient,
Value: &params.Name,
Required: true,
},
},
Expand Down
2 changes: 0 additions & 2 deletions cmd/state/internal/cmdtree/cmdtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func New(prime *primer.Values, args ...string) *CmdTree {
newSwitchCommand(prime),
newTestCommand(prime),
//newCommitCommand(prime), // re-enable in DX-2307
newPublish(prime),
)

return &CmdTree{
Expand All @@ -231,7 +230,6 @@ var (
VCSGroup = captain.NewCommandGroup(locale.Tl("group_vcs", "Version Control"), 5)
AutomationGroup = captain.NewCommandGroup(locale.Tl("group_automation", "Automation"), 4)
UtilsGroup = captain.NewCommandGroup(locale.Tl("group_utils", "Utilities"), 3)
AuthorGroup = captain.NewCommandGroup(locale.Tl("group_author", "Author"), 6)
)

func newGlobalOptions() *globalOptions {
Expand Down
22 changes: 3 additions & 19 deletions cmd/state/internal/cmdtree/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ func newInstallCommand(prime *primer.Values) *captain.Command {
locale.Tl("package_install_title", "Installing Package"),
locale.T("package_install_cmd_description"),
prime,
[]*captain.Flag{
{
Name: "ts",
Description: locale.T("package_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Flag{},
[]*captain.Argument{
{
Name: locale.T("package_arg_nameversion"),
Expand Down Expand Up @@ -94,7 +88,7 @@ func newUninstallCommand(prime *primer.Values) *captain.Command {
{
Name: locale.T("package_arg_name"),
Description: locale.T("package_arg_name_description"),
Value: &params.Package,
Value: &params.Name,
Required: true,
},
},
Expand Down Expand Up @@ -151,17 +145,12 @@ func newSearchCommand(prime *primer.Values) *captain.Command {
Description: locale.T("package_search_flag_exact-term_description"),
Value: &params.ExactTerm,
},
{
Name: "ts",
Description: locale.T("package_search_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Argument{
{
Name: locale.T("package_arg_name"),
Description: locale.T("package_arg_name_description"),
Value: &params.Ingredient,
Value: &params.Name,
Required: true,
},
},
Expand All @@ -187,11 +176,6 @@ func newInfoCommand(prime *primer.Values) *captain.Command {
Description: locale.T("package_info_flag_language_description"),
Value: &params.Language,
},
{
Name: "ts",
Description: locale.T("package_flag_ts_description"),
Value: &params.Timestamp,
},
},
[]*captain.Argument{
{
Expand Down
97 changes: 0 additions & 97 deletions cmd/state/internal/cmdtree/publish.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
Expand Down
14 changes: 6 additions & 8 deletions internal/assets/contents/usage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ Examples:
{{- end }}

{{- childCommands .Cmd}}
{{- if gt (len .Cmd.Arguments) 0}}

Arguments:
{{- range .Cmd.Arguments }}
<{{ .Name }}> {{ if .Required }} {{ else }}(optional){{ end }} {{ .Description }}
{{- end }}
{{- end }}

{{- if .Cobra.HasAvailableFlags}}

Flags:
Expand All @@ -39,7 +31,13 @@ Flags:
Global Flags:
{{.Cobra.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}
{{- end}}
{{- if gt (len .Cmd.Arguments) 0}}

Arguments:
{{- range .Cmd.Arguments }}
<{{ .Name }}> {{ if .Required }} {{ else }}(optional){{ end }} {{ .Description }}
{{- end }}
{{- end}}
{{- if .Cobra.HasHelpSubCommands}}

Additional help topics:
Expand Down
13 changes: 6 additions & 7 deletions internal/captain/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import (
"strings"

"github.com/ActiveState/cli/internal/errs"
"github.com/spf13/pflag"
)

type FlagMarshaler pflag.Value
type FlagMarshaler interface {
String() string
Set(string) error
Type() string
}

// Flag is used to define flags in our Command struct
type Flag struct {
Expand All @@ -35,10 +38,6 @@ func (c *Command) setFlags(flags []*Flag) error {
switch v := flag.Value.(type) {
case nil:
return errs.New("flag value must not be nil (%v)", flag)
case *[]string:
flagSetter().StringSliceVarP(
v, flag.Name, flag.Shorthand, *v, flag.Description,
)
case *string:
flagSetter().StringVarP(
v, flag.Name, flag.Shorthand, *v, flag.Description,
Expand All @@ -57,7 +56,7 @@ func (c *Command) setFlags(flags []*Flag) error {
)
default:
return errs.New(
fmt.Sprintf("Unknown type for flag %s: %s (%v)", flag.Name, reflect.TypeOf(v).Name(), v),
fmt.Sprintf("Unknown type: %s (%v)"+reflect.TypeOf(v).Name(), v),
)
}

Expand Down
40 changes: 40 additions & 0 deletions internal/captain/nameversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package captain

import (
"fmt"
"strings"

"github.com/ActiveState/cli/internal/locale"
)

type NameVersion struct {
name string
version string
}

func (nv *NameVersion) Set(arg string) error {
nameArg := strings.Split(arg, "@")
nv.name = nameArg[0]
if len(nameArg) == 2 {
nv.version = nameArg[1]
}
if len(nameArg) > 2 {
return locale.NewInputError("name_version_format_err", "Invalid format: Should be <name@version>")
}
return nil
}

func (nv *NameVersion) String() string {
if nv.version == "" {
return nv.name
}
return fmt.Sprintf("%s@%s", nv.name, nv.version)
}

func (nv *NameVersion) Name() string {
return nv.name
}

func (nv *NameVersion) Version() string {
return nv.version
}
Loading

0 comments on commit 98c0cde

Please sign in to comment.