resolveTemplateAlias reconciles --template and --snapshot. They're aliases, so using both with different values is an error; using only --snapshot copies its value into the shared template var.
(cmd *cobra.Command)
| 116 | // so using both with different values is an error; using only --snapshot copies |
| 117 | // its value into the shared template var. |
| 118 | func resolveTemplateAlias(cmd *cobra.Command) error { |
| 119 | templateSet := cmd.Flags().Changed("template") |
| 120 | snapshotSet := cmd.Flags().Changed("snapshot") |
| 121 | if templateSet && snapshotSet && template != snapshotAlias { |
| 122 | return usageErr("--template and --snapshot are aliases; use only one") |
| 123 | } |
| 124 | if snapshotSet && !templateSet { |
| 125 | template = snapshotAlias |
| 126 | } |
| 127 | return nil |
| 128 | } |
| 129 | |
| 130 | func hasAllCreateFlags(cmd *cobra.Command) bool { |
| 131 | return len(missingCreateFlags(cmd)) == 0 |