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>
46 lines
820 B
Go
46 lines
820 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.wntrmute.dev/kyle/arca/internal/config"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var configCmd = &cobra.Command{
|
|
Use: "config",
|
|
Short: "Manage arca configuration",
|
|
}
|
|
|
|
var configCheckCmd = &cobra.Command{
|
|
Use: "check",
|
|
Short: "Validate the config file",
|
|
RunE: runConfigCheck,
|
|
}
|
|
|
|
func init() {
|
|
configCmd.AddCommand(configCheckCmd)
|
|
rootCmd.AddCommand(configCmd)
|
|
}
|
|
|
|
func runConfigCheck(cmd *cobra.Command, args []string) error {
|
|
cfg := config.Load()
|
|
|
|
if len(cfg.Devices) == 0 {
|
|
fmt.Println("No devices configured.")
|
|
return nil
|
|
}
|
|
|
|
errs := config.Validate(cfg)
|
|
if len(errs) == 0 {
|
|
fmt.Printf("Config OK (%d device(s))\n", len(cfg.Devices))
|
|
return nil
|
|
}
|
|
|
|
for _, e := range errs {
|
|
fmt.Fprintln(os.Stderr, e)
|
|
}
|
|
return fmt.Errorf("config has %d issue(s)", len(errs))
|
|
}
|