Skip to content

Instantly share code, notes, and snippets.

@sarthaksarthak9
Created March 21, 2025 20:20
Show Gist options
  • Select an option

  • Save sarthaksarthak9/ac99e133e8d53e0fed6191d416f0db8d to your computer and use it in GitHub Desktop.

Select an option

Save sarthaksarthak9/ac99e133e8d53e0fed6191d416f0db8d to your computer and use it in GitHub Desktop.
package v1alpha

var _ plugin.InitSubcommand = &initSubcommand{}

type initSubcommand struct {
	config config.Config
}

func (p *initSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
	subcmdMeta.Description = metaDataDescription

	subcmdMeta.Examples = fmt.Sprintf(`  # Initialize a common project with this plugin
  %[1]s init --plugins=%[2]s
`, cliMeta.CommandName, pluginKey)
}

func (p *initSubcommand) InjectConfig(c config.Config) error {
	p.config = c
	return nil
}

func (p *initSubcommand) Scaffold(fs machinery.Filesystem) error {
	if err := InsertPluginMetaToConfig(p.config, pluginConfig{}); err != nil {
		return err
	}

	scaffolder := scaffolds.NewInitScaffolder()
	scaffolder.InjectFS(fs)
	return scaffolder.Scaffold()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment