本文整理汇总了Golang中github.com/ubuntu-core/snappy/i18n.G函数的典型用法代码示例。如果您正苦于以下问题:Golang G函数的具体用法?Golang G怎么用?Golang G使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Execute
func (x *cmdShell) Execute(args []string) error {
shellType := x.Positional.ShellType
if shellType == "classic" {
if !classic.Enabled() {
return fmt.Errorf(i18n.G(`Classic dimension disabled on this system.
Use "sudo snappy enable-classic" to enable it.`))
}
// we need to re-exec if we do not run as root
if os.Getuid() != 0 {
if err := reexecWithSudo(); err != nil {
return err
}
}
fmt.Println(i18n.G(`Entering classic dimension`))
fmt.Println(i18n.G(`
The home directory is shared between snappy and the classic dimension.
Run "exit" to leave the classic shell.
`))
return classic.RunShell()
}
return fmt.Errorf(i18n.G("unsupported shell %v"), shellType)
}
示例2: Execute
func (c *cmdChanges) Execute([]string) error {
if c.Positional.Id != "" {
return c.showChange(c.Positional.Id)
}
cli := Client()
changes, err := cli.Changes(client.ChangesAll)
if err != nil {
return err
}
if len(changes) == 0 {
return fmt.Errorf(i18n.G("no changes found"))
}
sort.Sort(changesByTime(changes))
w := tabWriter()
fmt.Fprintf(w, i18n.G("ID\tStatus\tSpawn\tReady\tSummary\n"))
for _, chg := range changes {
spawnTime := chg.SpawnTime.UTC().Format(time.RFC3339)
readyTime := chg.ReadyTime.UTC().Format(time.RFC3339)
if chg.ReadyTime.IsZero() {
readyTime = "-"
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", chg.ID, chg.Status, spawnTime, readyTime, chg.Summary)
}
w.Flush()
fmt.Fprintln(Stdout)
return nil
}
示例3: Execute
func (cmdList) Execute([]string) error {
cli := Client()
filter := client.SnapFilter{
Sources: []string{"local"},
}
snaps, _, err := cli.FilterSnaps(filter)
if err != nil {
return err
}
if len(snaps) == 0 {
return fmt.Errorf(i18n.G("no snaps found"))
}
sort.Sort(snapsByName(snaps))
w := tabWriter()
defer w.Flush()
fmt.Fprintln(w, i18n.G("Name\tVersion\tDeveloper"))
for _, snap := range snaps {
fmt.Fprintf(w, "%s\t%s\t%s\n", snap.Name, snap.Version, snap.Developer)
}
return nil
}
示例4: update
func (inst *snapInstruction) update() (*state.Change, error) {
flags := snappy.DoInstallGC
if inst.LeaveOld {
flags = 0
}
state := inst.overlord.State()
state.Lock()
msg := fmt.Sprintf(i18n.G("Refresh %q snap"), inst.pkg)
if inst.Channel != "stable" && inst.Channel != "" {
msg = fmt.Sprintf(i18n.G("Refresh %q snap from %q channel"), inst.pkg, inst.Channel)
}
chg := state.NewChange("refresh-snap", msg)
ts, err := snapstateUpdate(state, inst.pkg, inst.Channel, inst.userID, flags)
if err == nil {
chg.AddAll(ts)
}
state.Unlock()
if err != nil {
return nil, err
}
state.EnsureBefore(0)
return chg, nil
}
示例5: outputHWAccessForPkgname
func outputHWAccessForPkgname(pkgname string, writePaths []string) {
if len(writePaths) == 0 {
// TRANSLATORS: the %s is a pkgname
fmt.Printf(i18n.G("'%s:' is not allowed to access additional hardware\n"), pkgname)
} else {
// TRANSLATORS: the %s is a pkgname, the second a comma separated list of paths
fmt.Printf(i18n.G("%s: %s\n"), pkgname, strings.Join(writePaths, ", "))
}
}
示例6: init
func init() {
_, err := parser.AddCommand("console",
i18n.G("Run snappy console interface"),
i18n.G("Run snappy console interface"),
&cmdConsole{})
if err != nil {
logger.Panicf("Unable to console: %v", err)
}
}
示例7: init
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"))
}
示例8: init
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."))
}
示例9: init
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)"))
}
示例10: init
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."))
}
示例11: init
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)
}
}
示例12: init
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."))
}
示例13: init
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"))
}
示例14: init
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"))
}
示例15: init
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"))
}