MCPcopy
hub / github.com/cli/cli / NewCmdAlias

Function NewCmdAlias

pkg/cmd/root/alias.go:54–76  ·  view source on GitHub ↗
(io *iostreams.IOStreams, aliasName, aliasValue string)

Source from the content-addressed store, hash-verified

52}
53
54func NewCmdAlias(io *iostreams.IOStreams, aliasName, aliasValue string) *cobra.Command {
55 cmd := &cobra.Command{
56 Use: aliasName,
57 Short: fmt.Sprintf("Alias for %q", text.Truncate(80, aliasValue)),
58 RunE: func(c *cobra.Command, args []string) error {
59 expandedArgs, err := expandAlias(aliasValue, args)
60 if err != nil {
61 return err
62 }
63 root := c.Root()
64 root.SetArgs(expandedArgs)
65 return root.Execute()
66 },
67 GroupID: "alias",
68 DisableFlagParsing: true,
69 }
70 cmdutil.DisableAuthCheck(cmd)
71 // Aliases are user-defined names and must not be reported as telemetry
72 // dimensions, since the name itself may be sensitive (e.g. project or
73 // organization names).
74 cmdutil.DisableTelemetry(cmd)
75 return cmd
76}
77
78// ExpandAlias processes argv to see if it should be rewritten according to a user's aliases.
79func expandAlias(expansion string, args []string) ([]string, error) {

Callers 1

NewCmdRootFunction · 0.70

Calls 4

TruncateFunction · 0.92
DisableAuthCheckFunction · 0.92
DisableTelemetryFunction · 0.92
expandAliasFunction · 0.85

Tested by

no test coverage detected