Prepare encrypt/decrypt commands (#2)
This commit is contained in:
		
							parent
							
								
									dc9594c3f8
								
							
						
					
					
						commit
						f3cf37bdb0
					
				| @ -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) | ||||||
|  | |||||||
| @ -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 | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user