Add config validation, remove command, status filtering, and unlock method display
config check: validates UUID format, recognized methods, keyfile consistency and existence. Reports all issues with alias context. remove: deletes a device from config by alias. Inverse of add. status: --mounted, --unlocked, --locked flags filter the device table. Flags combine as OR. mount/unlock: display which method succeeded and key slot used, e.g. "(fido2, key slot 1)". cryptsetup Open now runs with -v and parses "Key slot N unlocked" from stderr via io.MultiWriter. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
38
cmd/remove.go
Normal file
38
cmd/remove.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.wntrmute.dev/kyle/arca/internal/config"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var removeCmd = &cobra.Command{
|
||||
Use: "remove <alias>",
|
||||
Short: "Remove a device from the config",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: runRemove,
|
||||
ValidArgsFunction: completeDeviceOrAlias,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(removeCmd)
|
||||
}
|
||||
|
||||
func runRemove(cmd *cobra.Command, args []string) error {
|
||||
alias := args[0]
|
||||
cfg := config.Load()
|
||||
|
||||
if _, ok := cfg.Devices[alias]; !ok {
|
||||
return fmt.Errorf("no device with alias %q in config", alias)
|
||||
}
|
||||
|
||||
delete(cfg.Devices, alias)
|
||||
|
||||
if err := cfg.Save(); err != nil {
|
||||
return fmt.Errorf("saving config: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Removed %q from config\n", alias)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user