Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DecryptCmd = &cobra.Command{ Use: "decrypt [file|directory]...", Short: "Decrypt the one or more files, creating a \"decrypted version\" that can be edited.", Long: "Decrypt the one or more files, creating a \"decrypted version\" that can be edited. Each arg can refer to either a file, in which case the file will be decrypted, or a directory, in which case all files under the directory will be decrypted. File args can refer to encrypted, decrypted, or plain files, existant or non-existant, as long as the correponding encrypted file exists. Supplying no args will decrypt all encrypted files in the repo.", Args: func(cmd *cobra.Command, args []string) error { if DecryptFlags.Stdout && len(args) != 1 { return errors.New("requires exactly 1 arg when --stdout is set") } return nil }, DisableFlagsInUseLine: true, RunE: func(cmd *cobra.Command, args []string) error { config, err := config.LoadConfig(".") if err != nil { return err } if len(args) == 0 { args = []string{config.Root} } for _, arg := range args { var files []string if info, err := os.Stat(arg); !os.IsNotExist(err) && info.IsDir() { files, err = config.AllEncryptedFiles(arg) if err != nil { return err } } else { files = []string{arg} } for _, file := range files { err = actions.Decrypt(actions.NewFile(file, &config), &config.Provider, DecryptFlags.Plain, DecryptFlags.Stdout, threads) if err != nil { return err } } } return nil }, }
View Source
var DecryptFlags struct { Stdout bool Plain bool }
View Source
var EncryptCmd = &cobra.Command{ Use: "encrypt [file|directory]...", Short: "Encrypt one or more decrypted files in the repo, replacing the contents of the encrypted files.", Long: "Encrypt one or more decrypted files in the repo, replacing the contents of the corresponding encrypted files. Each arg can refer to either a file, in which case the file will be encrypted, or a directory, in which case all files under the directory will be encrypted. File args can refer to encrypted, decrypted, or plain files, existant or non-existant, as long as the correponding decrypted file exists. Supplying no args will encrypt all decrypted files in the repo.", Args: cobra.ArbitraryArgs, DisableFlagsInUseLine: true, RunE: func(cmd *cobra.Command, args []string) error { config, err := config.LoadConfig(".") if err != nil { return err } if len(args) == 0 { args = []string{config.Root} } for _, arg := range args { var files []string if info, err := os.Stat(arg); !os.IsNotExist(err) && info.IsDir() { files, err = config.AllDecryptedFiles(arg) if err != nil { return err } } else { files = []string{arg} } for _, file := range files { err = actions.Encrypt(actions.NewFile(file, &config), &config.Provider, threads) if err != nil { return err } } } return nil }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.