(io *iostreams.IOStreams, aliasName, aliasValue string)
| 52 | } |
| 53 | |
| 54 | func 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. |
| 79 | func expandAlias(expansion string, args []string) ([]string, error) { |
no test coverage detected