func addProjectFlagsToCommands()

in astro/cli/astro/cmd/flags.go [92:118]


func addProjectFlagsToCommands(flags []*projectFlag, cmds ...*cobra.Command) {
	if len(flags) == 0 {
		return
	}

	projectFlagSet := flagsToFlagSet(flags)

	for _, cmd := range cmds {
		for _, flag := range flags {
			flag.AddToFlagSet(cmd.Flags())
		}

		// Update help text for the command to include the user flags
		helpTmpl := cmd.HelpTemplate()
		helpTmpl += "\nUser flags:\n"
		helpTmpl += projectFlagSet.FlagUsages()

		cmd.SetHelpTemplate(helpTmpl)

		// Mark flag hidden so it doesn't appear in the normal help. We have to
		// do this *after* calling flagUsages above, otherwise the flags don't
		// appear in the output.
		for _, flag := range flags {
			cmd.Flags().MarkHidden(flag.Name)
		}
	}
}