M4: CLI polish — version flag, mountpoint override, stable aliases
Add --version flag with build-time injection via ldflags. Add --mountpoint/-m flag to mount for one-off mount point override. Change init aliases from device path basename (sda1) to UUID prefix (b8b2f8e3) for stability across boots. Add .gitignore. Update flake.nix with version injection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
cmd/init.go
15
cmd/init.go
@@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
|
||||
"git.wntrmute.dev/kyle/arca/internal/config"
|
||||
"git.wntrmute.dev/kyle/arca/internal/udisks"
|
||||
"github.com/godbus/dbus/v5"
|
||||
@@ -62,7 +63,7 @@ func runInit(cmd *cobra.Command, args []string) error {
|
||||
continue
|
||||
}
|
||||
|
||||
alias := aliasFromPath(dev.DevicePath)
|
||||
alias := aliasFromUUID(dev.UUID)
|
||||
cfg.Devices[alias] = config.DeviceConfig{
|
||||
UUID: dev.UUID,
|
||||
Methods: []string{"passphrase"},
|
||||
@@ -101,8 +102,12 @@ func isRootBacking(path dbus.ObjectPath, rootDevices []dbus.ObjectPath) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func aliasFromPath(devPath string) string {
|
||||
// "/dev/sda1" -> "sda1", "/dev/nvme0n1p2" -> "nvme0n1p2"
|
||||
base := filepath.Base(devPath)
|
||||
return strings.TrimPrefix(base, "dm-")
|
||||
func aliasFromUUID(uuid string) string {
|
||||
// Use first 8 chars of UUID as a stable alias.
|
||||
// "b8b2f8e3-4cde-4aca-a96e-df9274019f9f" -> "b8b2f8e3"
|
||||
clean := strings.ReplaceAll(uuid, "-", "")
|
||||
if len(clean) > 8 {
|
||||
clean = clean[:8]
|
||||
}
|
||||
return clean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user