예제 #1
0
파일: main.go 프로젝트: dholbach/snappy
// Parser creates and populates a fresh parser.
// Since commands have local state a fresh parser is required to isolate tests
// from each other.
func Parser() *flags.Parser {
	parser := flags.NewParser(&optionsData, flags.HelpFlag|flags.PassDoubleDash)
	// Add all regular commands
	for _, c := range commands {
		cmd, err := parser.AddCommand(c.name, c.shortHelp, strings.TrimSpace(c.longHelp), c.builder())
		if err != nil {

			logger.Panicf("cannot add command %q: %v", c.name, err)
		}
		cmd.Hidden = c.hidden
	}
	// Add the experimental command
	experimentalCommand, err := parser.AddCommand("experimental", shortExperimentalHelp, longExperimentalHelp, &cmdExperimental{})
	experimentalCommand.Hidden = true
	if err != nil {
		logger.Panicf("cannot add command %q: %v", "experimental", err)
	}
	// Add all the sub-commands of the experimental command
	for _, c := range experimentalCommands {
		cmd, err := experimentalCommand.AddCommand(c.name, c.shortHelp, strings.TrimSpace(c.longHelp), c.builder())
		if err != nil {
			logger.Panicf("cannot add experimental command %q: %v", c.name, err)
		}
		cmd.Hidden = c.hidden
	}
	return parser
}
예제 #2
0
func init() {
	_, err := parser.AddCommand("enable-classic",
		i18n.G("Enable classic dimension."),
		i18n.G("Enable the ubuntu classic dimension."),
		&cmdEnableClassic{})
	if err != nil {
		logger.Panicf("Unable to enable-classic: %v", err)
	}

	_, err = parser.AddCommand("destroy-classic",
		i18n.G("Destroy the classic dimension."),
		i18n.G("Destroy the ubuntu classic dimension."),
		&cmdDestroyClassic{})
	if err != nil {
		logger.Panicf("Unable to destroy-classic: %v", err)
	}
}
예제 #3
0
func init() {
	_, err := parser.AddCommand("activate",
		i18n.G(`Activate a package`),
		i18n.G(`Activate a package that has previously been deactivated. If the package is already activated, do nothing.`),
		&cmdActivate{activate: true})
	if err != nil {
		logger.Panicf("Unable to activate: %v", err)
	}

	_, err = parser.AddCommand("deactivate",
		i18n.G(`Deactivate a package`),
		i18n.G(`Deactivate a package. If the package is already deactivated, do nothing.`),
		&cmdActivate{activate: false})
	if err != nil {
		logger.Panicf("Unable to deactivate: %v", err)
	}
}
예제 #4
0
파일: state.go 프로젝트: dholbach/snappy
func (data customData) set(key string, value interface{}) {
	serialized, err := json.Marshal(value)
	if err != nil {
		logger.Panicf("internal error: could not marshal value for state entry %q: %v", key, err)
	}
	entryJSON := json.RawMessage(serialized)
	data[key] = &entryJSON
}
예제 #5
0
파일: state.go 프로젝트: dholbach/snappy
func (s *State) checkpointData() []byte {
	data, err := json.Marshal(s)
	if err != nil {
		// this shouldn't happen, because the actual delicate serializing happens at various Set()s
		logger.Panicf("internal error: could not marshal state for checkpointing: %v", err)
	}
	return data
}
예제 #6
0
func init() {
	_, err := parser.AddCommand("grub-migrate",
		"internal",
		"internal",
		&cmdGrubMigrate{})
	if err != nil {
		logger.Panicf("Unable to grub-migrate: %v", err)
	}
}
예제 #7
0
func init() {
	_, err := parser.AddCommand("versions",
		shortVersionsHelp,
		longVersionsHelp,
		&cmdVersions{})
	if err != nil {
		logger.Panicf("Unable to versions: %v", err)
	}
}
예제 #8
0
func init() {
	_, err := parser.AddCommand("console",
		"Run snappy console interface",
		"Run snappy console interface",
		&cmdConsole{})
	if err != nil {
		logger.Panicf("Unable to console: %v", err)
	}
}
예제 #9
0
func init() {
	_, err := parser.AddCommand("firstboot",
		"internal",
		"internal",
		&cmdInternalFirstBootOemConfig{})
	if err != nil {
		logger.Panicf("Unable to first_boot: %v", err)
	}
}
예제 #10
0
func init() {
	_, err := parser.AddCommand("booted",
		"internal",
		"internal",
		&cmdBooted{})
	if err != nil {
		logger.Panicf("Unable to booted: %v", err)
	}
}
예제 #11
0
func init() {
	_, err := parser.AddCommand("internal-run-hooks",
		"internal",
		"internal",
		&cmdInternalRunHooks{})
	if err != nil {
		logger.Panicf("Unable to internal_run_hooks: %v", err)
	}
}
예제 #12
0
func init() {
	_, err := parser.AddCommand("set",
		i18n.G("Set properties of system or package"),
		setHelp,
		&cmdSet{})
	if err != nil {
		logger.Panicf("Unable to set: %v", err)
	}
}
예제 #13
0
func init() {
	_, err := parser.AddCommand("internal-unpack",
		"internal",
		"internal",
		&cmdInternalUnpack{})
	if err != nil {
		logger.Panicf("Unable to internal_unpack: %v", err)
	}
}
예제 #14
0
func init() {
	arg, err := parser.AddCommand("hw-info",
		shortHWInfoHelp,
		longHWInfoHelp,
		&cmdHWInfo{})
	if err != nil {
		logger.Panicf("Unable to hwinfo: %v", err)
	}
	addOptionDescription(arg, "package name", i18n.G("List assigned hardware for a specific installed package"))
}
예제 #15
0
func init() {
	arg, err := parser.AddCommand("shell",
		i18n.G("Run snappy shell interface"),
		i18n.G("Run snappy shell interface"),
		&cmdShell{})
	if err != nil {
		logger.Panicf("Unable to add shell command: %q", err)
	}
	addOptionDescription(arg, "shell-type", i18n.G("The type of shell you want"))
}
예제 #16
0
func init() {
	arg, err := parser.AddCommand("login",
		shortLoginHelp,
		longLoginHelp,
		&cmdLogin{})
	if err != nil {
		logger.Panicf("Unable to login: %v", err)
	}
	addOptionDescription(arg, "userid", i18n.G("Username for the login"))
}
예제 #17
0
func init() {
	arg, err := parser.AddCommand("purge",
		shortPurgeHelp,
		longPurgeHelp,
		&cmdPurge{})
	if err != nil {
		logger.Panicf("Unable to purge: %v", err)
	}
	addOptionDescription(arg, "installed", i18n.G("Purge an installed package."))
}
예제 #18
0
func init() {
	arg, err := parser.AddCommand("remove",
		i18n.G("Remove a snapp part"),
		i18n.G("Remove a snapp part"),
		&cmdRemove{})
	if err != nil {
		logger.Panicf("Unable to remove: %v", err)
	}
	addOptionDescription(arg, "no-gc", i18n.G("Do not clean up old versions of the package."))
}
예제 #19
0
파일: cmd_config.go 프로젝트: alecu/snappy
func init() {
	arg, err := parser.AddCommand("config",
		shortConfigHelp,
		longConfigHelp,
		&cmdConfig{})
	if err != nil {
		logger.Panicf("Unable to config: %v", err)
	}
	addOptionDescription(arg, "package name", i18n.G("Set configuration for a specific installed package"))
	addOptionDescription(arg, "config file", i18n.G("The configuration for the given file"))
}
예제 #20
0
func init() {
	_, err := parser.AddCommand("service",
		i18n.G("Query and modify snappy services"),
		i18n.G("Query and modify snappy services of locally-installed packages"),
		&cmdService{})

	if err != nil {
		logger.Panicf("Unable to service: %v", err)
	}

}
예제 #21
0
func init() {
	arg, err := parser.AddCommand("rollback",
		shortRollbackHelp,
		longRollbackHelp,
		&cmdRollback{})
	if err != nil {
		logger.Panicf("Unable to rollback: %v", err)
	}
	addOptionDescription(arg, "package name", i18n.G("The package to rollback "))
	addOptionDescription(arg, "version", i18n.G("The version to rollback to"))
}
예제 #22
0
func init() {
	arg, err := parser.AddCommand("update",
		i18n.G("Update all installed parts"),
		i18n.G("Ensures system is running with latest parts"),
		&cmdUpdate{})
	if err != nil {
		logger.Panicf("Unable to update: %v", err)
	}
	addOptionDescription(arg, "no-gc", i18n.G("Do not clean up old versions of the package."))
	addOptionDescription(arg, "automatic-reboot", i18n.G("Reboot if necessary to be on the latest running system."))
}
예제 #23
0
func init() {
	arg, err := parser.AddCommand("policygen",
		i18n.G("Generate the apparmor policy"),
		i18n.G("Generate the apparmor policy"),
		&cmdPolicygen{})
	if err != nil {
		logger.Panicf("Unable to install: %v", err)
	}
	addOptionDescription(arg, "force", i18n.G("Force policy generation."))
	addOptionDescription(arg, "package.yaml path", i18n.G("The path to the package.yaml used to generate the apparmor policy."))
}
예제 #24
0
func init() {
	arg, err := parser.AddCommand("hw-unassign",
		shortHWUnassignHelp,
		longHWUnassignHelp,
		&cmdHWUnassign{})
	if err != nil {
		logger.Panicf("Unable to hwunassign: %v", err)
	}
	addOptionDescription(arg, "package name", i18n.G("Remove hardware from a specific installed package"))
	addOptionDescription(arg, "device path", i18n.G("The hardware device path (e.g. /dev/ttyUSB0)"))
}
예제 #25
0
파일: cmd_info.go 프로젝트: alecu/snappy
func init() {
	arg, err := parser.AddCommand("info",
		shortInfoHelp,
		longInfoHelp,
		&cmdInfo{})
	if err != nil {
		logger.Panicf("Unable to info: %v", err)
	}
	addOptionDescription(arg, "verbose", i18n.G("Provides more detailed information"))
	addOptionDescription(arg, "include-remote", i18n.G("Include information about packages from the snappy store"))
	addOptionDescription(arg, "package name", i18n.G("Provide information about a specific installed package"))
}
예제 #26
0
func init() {
	cmd, err := parser.AddCommand("search",
		i18n.G("Search for packages to install"),
		i18n.G("Query the store for available packages"),
		&cmdSearch{})
	if err != nil {
		logger.Panicf("Unable to search: %v", err)
	}

	cmd.Aliases = append(cmd.Aliases, "se")
	addOptionDescription(cmd, "show-all", i18n.G("Show all available forks of a package"))
}
예제 #27
0
func init() {
	cmd, err := parser.AddCommand("build",
		i18n.G("Builds a snap package"),
		longBuildHelp,
		&cmdBuild{})
	if err != nil {
		logger.Panicf("Unable to build: %v", err)
	}

	cmd.Aliases = append(cmd.Aliases, "bu")
	addOptionDescription(cmd, "output", i18n.G("Specify an alternate output directory for the resulting package"))
}
예제 #28
0
func fillSnapEnvVars(desc interface{}, vars []string) []string {
	for i, v := range vars {
		var templateOut bytes.Buffer
		t := template.Must(template.New("wrapper").Parse(v))
		if err := t.Execute(&templateOut, desc); err != nil {
			// this can never happen, except we forget a variable
			logger.Panicf("Unable to execute template: %v", err)
		}
		vars[i] = templateOut.String()
	}
	return vars
}
예제 #29
0
func init() {
	arg, err := parser.AddCommand("install",
		i18n.G("Install a snap package"),
		i18n.G("Install a snap package"),
		&cmdInstall{})
	if err != nil {
		logger.Panicf("Unable to install: %v", err)
	}
	addOptionDescription(arg, "allow-unauthenticated", i18n.G("Install snaps even if the signature can not be verified."))
	addOptionDescription(arg, "no-gc", i18n.G("Do not clean up old versions of the package."))
	addOptionDescription(arg, "package name", i18n.G("The Package to install (name or path)"))
	addOptionDescription(arg, "config file", i18n.G("The configuration for the given install"))
}
예제 #30
0
func init() {
	cmd, err := parser.AddCommand("list",
		shortListHelp,
		longListHelp,
		&cmdList{})
	if err != nil {
		logger.Panicf("Unable to list: %v", err)
	}

	cmd.Aliases = append(cmd.Aliases, "li")
	addOptionDescription(cmd, "updates", i18n.G("Show available updates (requires network)"))
	addOptionDescription(cmd, "verbose", i18n.G("Show channel information and expand all fields"))
}