()
| 59 | } |
| 60 | |
| 61 | func main() { |
| 62 | // Parse flags early to get --dbPath before initializing database |
| 63 | // We need to manually parse --dbPath because it can appear after the subcommand |
| 64 | // (e.g., "dnote sync --full --dbPath=./custom.db") and root.ParseFlags only |
| 65 | // parses flags before the subcommand. |
| 66 | dbPath := parseDBPath(os.Args[1:]) |
| 67 | |
| 68 | // Initialize context - defaultAPIEndpoint is used when creating new config file |
| 69 | ctx, err := infra.Init(versionTag, apiEndpoint, dbPath) |
| 70 | if err != nil { |
| 71 | panic(errors.Wrap(err, "initializing context")) |
| 72 | } |
| 73 | defer ctx.DB.Close() |
| 74 | |
| 75 | root.Register(remove.NewCmd(*ctx)) |
| 76 | root.Register(edit.NewCmd(*ctx)) |
| 77 | root.Register(login.NewCmd(*ctx)) |
| 78 | root.Register(logout.NewCmd(*ctx)) |
| 79 | root.Register(add.NewCmd(*ctx)) |
| 80 | root.Register(sync.NewCmd(*ctx)) |
| 81 | root.Register(version.NewCmd(*ctx)) |
| 82 | root.Register(view.NewCmd(*ctx)) |
| 83 | root.Register(find.NewCmd(*ctx)) |
| 84 | |
| 85 | if err := root.Execute(); err != nil { |
| 86 | log.Errorf("%s\n", err.Error()) |
| 87 | os.Exit(1) |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected