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 } cache, err := cache.Setup(config) if err != nil { return err } defer cache.Close() if len(args) == 0 { args = []string{config.Root} } files := make([]*actions.File, 0, len(args)) for _, arg := range args { var paths []string if info, err := os.Stat(arg); !os.IsNotExist(err) && info.IsDir() { paths, err = config.AllEncryptedFiles(arg) if err != nil { return err } } else { paths = []string{arg} } for _, path := range paths { file, err := actions.NewFile(path, &config) if err != nil { return err } files = append(files, &file) } } return actions.Decrypt(files, DecryptFlags.Plain, DecryptFlags.Stdout, &cache, &config.Provider, int(threads)) }, }
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 } cache, err := cache.Setup(config) if err != nil { return err } defer cache.Close() if len(args) == 0 { args = []string{config.Root} } files := make([]*actions.File, 0, len(args)) for _, arg := range args { var paths []string if info, err := os.Stat(arg); !os.IsNotExist(err) && info.IsDir() { paths, err = config.AllDecryptedFiles(arg) if err != nil { return err } } else { paths = []string{arg} } for _, path := range paths { file, err := actions.NewFile(path, &config) if err != nil { return err } files = append(files, &file) } } return actions.Encrypt(files, &cache, &config.Provider, int(threads)) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.