| 18 | } |
| 19 | |
| 20 | func (c *createCmd) Command(celer *configs.Celer) *cobra.Command { |
| 21 | c.celer = celer |
| 22 | command := &cobra.Command{ |
| 23 | Use: "create", |
| 24 | Short: "Create a platform, project or port.", |
| 25 | Long: `Create a platform, project or port. |
| 26 | |
| 27 | This command helps you scaffold new configurations for different components |
| 28 | in the celer package manager. You must specify exactly one type of component |
| 29 | to create using the mutually exclusive flags. |
| 30 | |
| 31 | COMPONENT TYPES: |
| 32 | --platform Create a new platform configuration (e.g., windows-x86_64, linux-x64) |
| 33 | --project Create a new project configuration |
| 34 | --port Create a new port with name@version format |
| 35 | |
| 36 | EXAMPLES: |
| 37 | celer create --platform windows-x86_64-msvc |
| 38 | celer create --project my-awesome-project |
| 39 | celer create --port opencv@4.8.0`, |
| 40 | Args: cobra.NoArgs, |
| 41 | RunE: func(cmd *cobra.Command, args []string) error { |
| 42 | return c.doCreate(cmd) |
| 43 | }, |
| 44 | ValidArgsFunction: c.completion, |
| 45 | } |
| 46 | |
| 47 | // Register flags. |
| 48 | command.Flags().StringVar(&c.platform, "platform", "", "create a new platform.") |
| 49 | command.Flags().StringVar(&c.project, "project", "", "create a new project.") |
| 50 | command.Flags().StringVar(&c.port, "port", "", "create a new port.") |
| 51 | |
| 52 | command.MarkFlagsMutuallyExclusive("platform", "project", "port") |
| 53 | |
| 54 | // Silence cobra's error and usage output to avoid duplicate messages. |
| 55 | command.SilenceErrors = true |
| 56 | command.SilenceUsage = true |
| 57 | return command |
| 58 | } |
| 59 | |
| 60 | func (c *createCmd) createPlatform(platformName string) error { |
| 61 | if err := c.celer.CreatePlatform(platformName); err != nil { |