Documentation ¶
Overview ¶
Package cmd some useful tools for command argument
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EncryptAESCMD = &cobra.Command{ Use: "aes", Short: "encrypt file by aes, key's length must be 16/24/32", Long: `encrypt file by aes`, PreRunE: func(cmd *cobra.Command, args []string) error { return setupEncryptAESArgs(cmd) }, Run: func(cmd *cobra.Command, args []string) { fs, err := os.Stat(inputpath) if err != nil { log.Shared.Panic("read path", zap.Error(err)) } if fs.IsDir() { if err = encryptDirFileByAes(); err != nil { log.Shared.Panic("encrypt files in dir", zap.Error(err)) } } else { if err = encryptFileByAes(); err != nil { log.Shared.Panic("encrypt file", zap.Error(err)) } } }, }
EncryptAESCMD encrypt files by aes
`go run cmd/main/main.go encrypt aes -i cmd/root.go -s 123`
View Source
var EncryptCMD = &cobra.Command{ Use: "encrypt", Short: "encrypt file or directory", Long: gutils.Dedent(` encrypt file or directory by aes Usage import ( gcmd "github.com/Laisky/go-utils/v4/cmd" ) func init() { rootCMD.AddCommand(gcmd.EncryptCMD) } Run go run -race main.go encrypt aes -i <file_path> -s <password> `), Args: NoExtraArgs, }
EncryptCMD encrypt files
View Source
var RSA = &cobra.Command{ Use: "rsa", Short: "rsa", Args: NoExtraArgs, Run: func(cmd *cobra.Command, args []string) { }, }
RSA some rsa command tools
View Source
var RSASign = &cobra.Command{ Use: "sign", Short: "sign by RSA & SHA256", Args: NoExtraArgs, Run: func(cmd *cobra.Command, args []string) { err := SignFileByRSA(rsaPrikeyPemFilepath, fileWantToSignature) if err != nil { log.Shared.Panic("sign by rsa", zap.Error(err)) } }, }
RSASign sign file by rsa
View Source
var RSAVerify = &cobra.Command{ Use: "verify", Short: "verify by RSA & SHA256", Args: NoExtraArgs, Run: func(cmd *cobra.Command, args []string) { err := VerifyFileByRSA(rsaPubkeyPemFilepath, fileWantToSignature) if err != nil { log.Shared.Panic("verify by rsa", zap.Error(err)) } }, }
RSAVerify verify file by rsa
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func NoExtraArgs ¶
NoExtraArgs make sure every args has been processed
do not allow any unprocessed args
Example ¶
use with cobra.Command:
cmd = &cobra.Command{ Args: NoExtraArgs, }
func SignFileByRSA ¶
SignFileByRSA sign file by rsa
func VerifyFileByRSA ¶
VerifyFileByRSA verify file by rsa
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.