refactor: replace explicit fields with tag-based property system

This commit is contained in:
2026-03-27 02:11:46 +01:00
parent 2d4cff717b
commit b2225cff7b
17 changed files with 485 additions and 825 deletions

View File

@@ -11,28 +11,23 @@ import (
)
var initCmd = &cobra.Command{
Use: "init [path]",
Short: "Initialize a new database",
Args: cobra.MaximumNArgs(1),
Use: "init [path]", Short: "Initialize a new database", Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
path := "."
p := "."
if len(args) > 0 {
path = args[0]
p = args[0]
}
dbPath := filepath.Join(path, ".ax.db")
dbPath := filepath.Join(p, ".ax.db")
if _, err := os.Stat(dbPath); err == nil {
fmt.Fprintln(os.Stderr, "database already exists:", dbPath)
os.Exit(1)
}
err := db.Init(dbPath)
if err != nil {
if err := db.Init(dbPath); err != nil {
fmt.Fprintln(os.Stderr, "failed to initialize:", err)
os.Exit(1)
}
output.PrintCreated(cmd.OutOrStdout(), dbPath)
output.PrintAction(cmd.OutOrStdout(), "Created", dbPath, false)
},
}
func init() {
rootCmd.AddCommand(initCmd)
}
func init() { rootCmd.AddCommand(initCmd) }