Compare commits
	
		
			No commits in common. "2a1e0337fd46913d547072b6e518e73fdf0289b6" and "dd2e95f8af45fa93a3d3b0ace80175735a7e4623" have entirely different histories.
		
	
	
		
			2a1e0337fd
			...
			dd2e95f8af
		
	
		
@ -22,7 +22,3 @@ Read the rules in AGENTS.md and follow them.
 | 
			
		||||
* The test suite is fast and local.  When running tests, don't run
 | 
			
		||||
  individual parts of the test suite, always run the whole thing by running
 | 
			
		||||
  "make test".
 | 
			
		||||
 | 
			
		||||
* Do not stop working on a task until you have reached the definition of
 | 
			
		||||
  done provided to you in the initial instruction.  Don't do part or most of
 | 
			
		||||
  the work, do all of the work until the criteria for done are met.
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,6 @@ type Instance struct {
 | 
			
		||||
func NewCLIInstance() *Instance {
 | 
			
		||||
	fs := afero.NewOsFs()
 | 
			
		||||
	stateDir := secret.DetermineStateDir("")
 | 
			
		||||
 | 
			
		||||
	return &Instance{
 | 
			
		||||
		fs:       fs,
 | 
			
		||||
		stateDir: stateDir,
 | 
			
		||||
@ -71,7 +70,6 @@ func getStdinScanner() *bufio.Scanner {
 | 
			
		||||
	if stdinScanner == nil {
 | 
			
		||||
		stdinScanner = bufio.NewScanner(os.Stdin)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return stdinScanner
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -89,9 +87,7 @@ func readLineFromStdin(prompt string) (string, error) {
 | 
			
		||||
		if err := scanner.Err(); err != nil {
 | 
			
		||||
			return "", fmt.Errorf("failed to read from stdin: %w", err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return "", fmt.Errorf("failed to read from stdin: EOF")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return strings.TrimSpace(scanner.Text()), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,14 +23,12 @@ func newEncryptCmd() *cobra.Command {
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
			cli.cmd = cmd
 | 
			
		||||
 | 
			
		||||
			return cli.Encrypt(args[0], inputFile, outputFile)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().StringP("input", "i", "", "Input file (default: stdin)")
 | 
			
		||||
	cmd.Flags().StringP("output", "o", "", "Output file (default: stdout)")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -46,14 +44,12 @@ func newDecryptCmd() *cobra.Command {
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
			cli.cmd = cmd
 | 
			
		||||
 | 
			
		||||
			return cli.Decrypt(args[0], inputFile, outputFile)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().StringP("input", "i", "", "Input file (default: stdin)")
 | 
			
		||||
	cmd.Flags().StringP("output", "o", "", "Output file (default: stdout)")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -50,7 +50,6 @@ func newGenerateSecretCmd() *cobra.Command {
 | 
			
		||||
			force, _ := cmd.Flags().GetBool("force")
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.GenerateSecret(cmd, args[0], length, secretType, force)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
@ -135,7 +134,6 @@ func (cli *Instance) GenerateSecret(
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Printf("Generated and stored %d-character %s secret: %s\n", length, secretType, secretName)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -42,6 +42,5 @@ func newRootCmd() *cobra.Command {
 | 
			
		||||
	cmd.AddCommand(newVersionCmd())
 | 
			
		||||
 | 
			
		||||
	secret.Debug("newRootCmd completed")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -26,13 +26,11 @@ func newAddCmd() *cobra.Command {
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
			cli.cmd = cmd // Set the command for stdin access
 | 
			
		||||
			secret.Debug("Created CLI instance, calling AddSecret")
 | 
			
		||||
 | 
			
		||||
			return cli.AddSecret(args[0], force)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().BoolP("force", "f", false, "Overwrite existing secret")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -44,13 +42,11 @@ func newGetCmd() *cobra.Command {
 | 
			
		||||
		RunE: func(cmd *cobra.Command, args []string) error {
 | 
			
		||||
			version, _ := cmd.Flags().GetString("version")
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.GetSecretWithVersion(cmd, args[0], version)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().StringP("version", "v", "", "Get a specific version (default: current)")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -70,13 +66,11 @@ func newListCmd() *cobra.Command {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.ListSecrets(cmd, jsonOutput, filter)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().Bool("json", false, "Output in JSON format")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -91,7 +85,6 @@ func newImportCmd() *cobra.Command {
 | 
			
		||||
			force, _ := cmd.Flags().GetBool("force")
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.ImportSecret(cmd, args[0], sourceFile, force)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
@ -99,7 +92,6 @@ func newImportCmd() *cobra.Command {
 | 
			
		||||
	cmd.Flags().StringP("source", "s", "", "Source file to import from (required)")
 | 
			
		||||
	cmd.Flags().BoolP("force", "f", false, "Overwrite existing secret")
 | 
			
		||||
	_ = cmd.MarkFlagRequired("source")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -139,7 +131,6 @@ func (cli *Instance) AddSecret(secretName string, force bool) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	secret.Debug("vault.AddSecret completed successfully")
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -255,7 +246,6 @@ func (cli *Instance) ListSecrets(cmd *cobra.Command, jsonOutput bool, filter str
 | 
			
		||||
				cmd.Println("No secrets found in current vault.")
 | 
			
		||||
				cmd.Println("Run 'secret add <name>' to create one.")
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -307,6 +297,5 @@ func (cli *Instance) ImportSecret(cmd *cobra.Command, secretName, sourceFile str
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Printf("Successfully imported secret '%s' from file '%s'\n", secretName, sourceFile)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -41,13 +41,11 @@ func newUnlockersListCmd() *cobra.Command {
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
			cli.cmd = cmd
 | 
			
		||||
 | 
			
		||||
			return cli.UnlockersList(jsonOutput)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().Bool("json", false, "Output in JSON format")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -64,7 +62,6 @@ func newUnlockersAddCmd() *cobra.Command {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().String("keyid", "", "GPG key ID for PGP unlockers")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -172,7 +169,6 @@ func (cli *Instance) UnlockersList(jsonOutput bool) error {
 | 
			
		||||
				case "pgp":
 | 
			
		||||
					unlocker = secret.NewPGPUnlocker(cli.fs, unlockerDir, diskMetadata)
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@ -212,7 +208,6 @@ func (cli *Instance) UnlockersList(jsonOutput bool) error {
 | 
			
		||||
		if len(unlockers) == 0 {
 | 
			
		||||
			cli.cmd.Println("No unlockers found in current vault.")
 | 
			
		||||
			cli.cmd.Println("Run 'secret unlockers add passphrase' to create one.")
 | 
			
		||||
 | 
			
		||||
			return nil
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -268,7 +263,6 @@ func (cli *Instance) UnlockersAdd(unlockerType string, cmd *cobra.Command) error
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		cmd.Printf("Created passphrase unlocker: %s\n", passphraseUnlocker.GetID())
 | 
			
		||||
 | 
			
		||||
		return nil
 | 
			
		||||
 | 
			
		||||
	case "keychain":
 | 
			
		||||
@ -281,7 +275,6 @@ func (cli *Instance) UnlockersAdd(unlockerType string, cmd *cobra.Command) error
 | 
			
		||||
		if keyName, err := keychainUnlocker.GetKeychainItemName(); err == nil {
 | 
			
		||||
			cmd.Printf("Keychain Item Name: %s\n", keyName)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return nil
 | 
			
		||||
 | 
			
		||||
	case "pgp":
 | 
			
		||||
@ -302,7 +295,6 @@ func (cli *Instance) UnlockersAdd(unlockerType string, cmd *cobra.Command) error
 | 
			
		||||
 | 
			
		||||
		cmd.Printf("Created PGP unlocker: %s\n", pgpUnlocker.GetID())
 | 
			
		||||
		cmd.Printf("GPG Key ID: %s\n", gpgKeyID)
 | 
			
		||||
 | 
			
		||||
		return nil
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
 | 
			
		||||
@ -38,13 +38,11 @@ func newVaultListCmd() *cobra.Command {
 | 
			
		||||
			jsonOutput, _ := cmd.Flags().GetBool("json")
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.ListVaults(cmd, jsonOutput)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Flags().Bool("json", false, "Output in JSON format")
 | 
			
		||||
 | 
			
		||||
	return cmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -85,7 +83,6 @@ func newVaultImportCmd() *cobra.Command {
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			cli := NewCLIInstance()
 | 
			
		||||
 | 
			
		||||
			return cli.VaultImport(cmd, vaultName)
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
@ -150,7 +147,6 @@ func (cli *Instance) CreateVault(cmd *cobra.Command, name string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Printf("Created vault '%s'\n", vlt.GetName())
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -161,7 +157,6 @@ func (cli *Instance) SelectVault(cmd *cobra.Command, name string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	cmd.Printf("Selected vault '%s' as current\n", name)
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -48,7 +48,6 @@ func VersionCommands(cli *Instance) *cobra.Command {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	versionCmd.AddCommand(listCmd, promoteCmd)
 | 
			
		||||
 | 
			
		||||
	return versionCmd
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -155,7 +154,6 @@ func (cli *Instance) ListVersions(cmd *cobra.Command, secretName string) error {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	w.Flush()
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,6 @@ func EncryptToRecipient(data []byte, recipient age.Recipient) ([]byte, error) {
 | 
			
		||||
 | 
			
		||||
	result := buf.Bytes()
 | 
			
		||||
	Debug("EncryptToRecipient completed successfully", "result_length", len(result))
 | 
			
		||||
 | 
			
		||||
	return result, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -113,7 +113,6 @@ func (h *colorizedHandler) Handle(_ context.Context, record slog.Record) error {
 | 
			
		||||
			}
 | 
			
		||||
			first = false
 | 
			
		||||
			output += fmt.Sprintf("%s=%#v", attr.Key, attr.Value.Any())
 | 
			
		||||
 | 
			
		||||
			return true
 | 
			
		||||
		})
 | 
			
		||||
		output += "}\033[0m"
 | 
			
		||||
@ -121,7 +120,6 @@ func (h *colorizedHandler) Handle(_ context.Context, record slog.Record) error {
 | 
			
		||||
 | 
			
		||||
	output += "\n"
 | 
			
		||||
	_, err := h.output.Write([]byte(output))
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user