detached c03e113

feat(cli): add archup-installer command entry point with version and cleanup flags

commit
c03e113de825040fe12e7dac025075dd746a8bad
author
bnema · · 2025-10-26 09:42 UTC
parent
1e96984
signature
unsigned
1 file · +81 -0
A cmd/archup-installer/main.go +81 -0
@@ -0,0 +1,81 @@
1+package main
2+
3+import (
4+ "flag"
5+ "fmt"
6+ "os"
7+
8+ tea "github.com/charmbracelet/bubbletea"
9+ "github.com/bnema/archup/internal/cleanup"
10+ "github.com/bnema/archup/internal/config"
11+ "github.com/bnema/archup/internal/logger"
12+ "github.com/bnema/archup/internal/phases"
13+ "github.com/bnema/archup/internal/ui"
14+)
15+
16+// version is set via ldflags at build time
17+// Example: go build -ldflags "-X main.version=v0.3.0"
18+var version = "dev"
19+
20+func main() {
21+ // Parse command-line flags
22+ var (
23+ showVersion = flag.Bool("version", false, "Show version and exit")
24+ doCleanup = flag.Bool("cleanup", false, "Clean up installation artifacts and exit")
25+ dryRun = flag.Bool("dry-run", false, "Show TUI but don't execute commands")
26+ )
27+ flag.Parse()
28+
29+ // Handle --version flag
30+ if *showVersion {
31+ fmt.Printf("archup-installer %s\n", version)
32+ os.Exit(0)
33+ }
34+
35+ // Create logger with dry-run mode
36+ log, err := logger.New(config.DefaultLogPath, *dryRun)
37+ if err != nil {
38+ fmt.Fprintf(os.Stderr, "Failed to create logger: %v\n", err)
39+ os.Exit(1)
40+ }
41+
42+ // Handle --cleanup flag
43+ if *doCleanup {
44+ if err := cleanup.Run(log); err != nil {
45+ fmt.Fprintf(os.Stderr, "Cleanup failed: %v\n", err)
46+ os.Exit(1)
47+ }
48+ os.Exit(0)
49+ }
50+
51+ // Log dry-run mode if enabled
52+ if *dryRun {
53+ log.Info("Running in DRY-RUN mode - commands will be logged but not executed")
54+ }
55+
56+ // Load or create config
57+ cfg := config.NewConfig()
58+
59+ // Initialize orchestrator
60+ orchestrator := phases.NewOrchestrator(cfg, config.DefaultLogPath)
61+
62+ // Register all phases with logger
63+ orchestrator.RegisterPhase(phases.NewBootstrapPhase(cfg, log))
64+ orchestrator.RegisterPhase(phases.NewPreflightPhase(cfg, log))
65+ orchestrator.RegisterPhase(phases.NewPartitioningPhase(cfg, log))
66+ orchestrator.RegisterPhase(phases.NewBaseInstallPhase(cfg, log))
67+ orchestrator.RegisterPhase(phases.NewConfigPhase(cfg, log))
68+ orchestrator.RegisterPhase(phases.NewBootPhase(cfg, log))
69+ orchestrator.RegisterPhase(phases.NewReposPhase(cfg, log))
70+ orchestrator.RegisterPhase(phases.NewPostInstallPhase(cfg, log))
71+
72+ // Create UI model
73+ model := ui.NewModel(orchestrator, cfg, version)
74+
75+ // Run Bubbletea app
76+ p := tea.NewProgram(model, tea.WithAltScreen())
77+ if _, err := p.Run(); err != nil {
78+ fmt.Printf("Error running installer: %v\n", err)
79+ os.Exit(1)
80+ }
81+}
@@ -0,0 +1,81 @@
1+package main
2+
3+import (
4+ "flag"
5+ "fmt"
6+ "os"
7+
8+ tea "github.com/charmbracelet/bubbletea"
9+ "github.com/bnema/archup/internal/cleanup"
10+ "github.com/bnema/archup/internal/config"
11+ "github.com/bnema/archup/internal/logger"
12+ "github.com/bnema/archup/internal/phases"
13+ "github.com/bnema/archup/internal/ui"
14+)
15+
16+// version is set via ldflags at build time
17+// Example: go build -ldflags "-X main.version=v0.3.0"
18+var version = "dev"
19+
20+func main() {
21+ // Parse command-line flags
22+ var (
23+ showVersion = flag.Bool("version", false, "Show version and exit")
24+ doCleanup = flag.Bool("cleanup", false, "Clean up installation artifacts and exit")
25+ dryRun = flag.Bool("dry-run", false, "Show TUI but don't execute commands")
26+ )
27+ flag.Parse()
28+
29+ // Handle --version flag
30+ if *showVersion {
31+ fmt.Printf("archup-installer %s\n", version)
32+ os.Exit(0)
33+ }
34+
35+ // Create logger with dry-run mode
36+ log, err := logger.New(config.DefaultLogPath, *dryRun)
37+ if err != nil {
38+ fmt.Fprintf(os.Stderr, "Failed to create logger: %v\n", err)
39+ os.Exit(1)
40+ }
41+
42+ // Handle --cleanup flag
43+ if *doCleanup {
44+ if err := cleanup.Run(log); err != nil {
45+ fmt.Fprintf(os.Stderr, "Cleanup failed: %v\n", err)
46+ os.Exit(1)
47+ }
48+ os.Exit(0)
49+ }
50+
51+ // Log dry-run mode if enabled
52+ if *dryRun {
53+ log.Info("Running in DRY-RUN mode - commands will be logged but not executed")
54+ }
55+
56+ // Load or create config
57+ cfg := config.NewConfig()
58+
59+ // Initialize orchestrator
60+ orchestrator := phases.NewOrchestrator(cfg, config.DefaultLogPath)
61+
62+ // Register all phases with logger
63+ orchestrator.RegisterPhase(phases.NewBootstrapPhase(cfg, log))
64+ orchestrator.RegisterPhase(phases.NewPreflightPhase(cfg, log))
65+ orchestrator.RegisterPhase(phases.NewPartitioningPhase(cfg, log))
66+ orchestrator.RegisterPhase(phases.NewBaseInstallPhase(cfg, log))
67+ orchestrator.RegisterPhase(phases.NewConfigPhase(cfg, log))
68+ orchestrator.RegisterPhase(phases.NewBootPhase(cfg, log))
69+ orchestrator.RegisterPhase(phases.NewReposPhase(cfg, log))
70+ orchestrator.RegisterPhase(phases.NewPostInstallPhase(cfg, log))
71+
72+ // Create UI model
73+ model := ui.NewModel(orchestrator, cfg, version)
74+
75+ // Run Bubbletea app
76+ p := tea.NewProgram(model, tea.WithAltScreen())
77+ if _, err := p.Run(); err != nil {
78+ fmt.Printf("Error running installer: %v\n", err)
79+ os.Exit(1)
80+ }
81+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close