Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConvBaseCmd = &gcli.Command{ Name: "conv-base", Aliases: []string{"base", "cb"}, Desc: "Convert base data type. eg: binary, decimal(10), base8, hex(16), base64, base32 ...", Config: func(c *gcli.Command) { c.MustFromStruct(&convBaseOpts) c.AddArg("input", "want convert base string contents") }, Func: func(c *gcli.Command, _ []string) (err error) { str := c.Arg("input").String() str, err = apputil.ReadSource(str) if err != nil { return err } c.Infoln("Input String:", str) c.Warnln("Conv Results:") commonBases := []int{2, 10, 16, 32, 36, 62, 64} if convBaseOpts.To < 2 { for _, toBase := range commonBases { if toBase == convBaseOpts.From { continue } dst := strutil.BaseConv(str, convBaseOpts.From, toBase) fmt.Printf("convert to %d: %s\n", toBase, dst) } } else { dst := strutil.BaseConv(str, convBaseOpts.From, convBaseOpts.To) fmt.Printf("convert to %d: %s\n", convBaseOpts.To, dst) } return }, }
ConvBaseCmd command Base Binary decimal Base 8
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.