Prepare encrypt/decrypt commands (#2)

This commit is contained in:
Andreas Schneider 2018-04-06 19:33:20 +02:00
parent dc9594c3f8
commit f3cf37bdb0
2 changed files with 35 additions and 1 deletions

View File

@ -9,12 +9,14 @@ import (
) )
func main() { func main() {
rootCmd := cobra.Command{ rootCmd := &cobra.Command{
Use: "calanonsync", Use: "calanonsync",
Short: "Synchronize a calendar from EWS to CalDAV by event time and an anonymized title only.", Short: "Synchronize a calendar from EWS to CalDAV by event time and an anonymized title only.",
Run: runSynchronization, Run: runSynchronization,
} }
rootCmd.AddCommand(InitSettingsCmd())
if err := rootCmd.Execute(); err != nil { if err := rootCmd.Execute(); err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)

View File

@ -2,6 +2,8 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal" "golang.org/x/crypto/ssh/terminal"
"os" "os"
"strings" "strings"
@ -58,3 +60,33 @@ func LoadSettings() Settings {
return settings return settings
} }
func InitSettingsCmd() *cobra.Command {
settingsCmd := &cobra.Command{
Use: "settings",
Short: "Manage settings.",
}
encryptCmd := &cobra.Command{
Use: "encrypt",
Short: "Encrypt the passwords in the settings file.",
Long: `This will encrypt the passwords in the settings file that are
not empty. It will generate a new "master" password and store that alongside
the settings file. This is NOT secure, it just helps to prevent
over-the-shoulder "attacks".`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Encrypt")
},
}
decryptCmd := &cobra.Command{
Use: "decrypt",
Short: "Decrypt a previously encrypted settings file.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Decrypt")
},
}
settingsCmd.AddCommand(encryptCmd, decryptCmd)
return settingsCmd
}