MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / getHostIdFromFlagsAndArgs

Function getHostIdFromFlagsAndArgs

cli/cmd/host/host-get.go:74–95  ·  view source on GitHub ↗

获取工作区id

(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

72
73// 获取工作区id
74func getHostIdFromFlagsAndArgs(cmd *cobra.Command, args []string) int {
75 fflags := cmd.Flags()
76
77 // 从args 或者 flag 中获取值
78 var hostId int
79 if len(args) > 0 { // 从args中加载
80 str := args[0]
81 tmpHostId, err := strconv.Atoi(str)
82 if err == nil && tmpHostId > 0 {
83 hostId = tmpHostId
84 }
85
86 } else if fflags.Changed(flag_hostid) { // 从flag中加载
87 tmpHostId, err := fflags.GetInt32(flag_hostid)
88 common.CheckError(err)
89 if tmpHostId > 0 {
90 hostId = int(tmpHostId)
91 }
92 }
93
94 return hostId
95}
96
97func init() {
98 HostGetCmd.Flags().Int32P("hostid", "r", 0, i18nInstance.Host.Info_help_flag_hostid)

Callers 2

host-get.goFile · 0.85
host-remove.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected