feat(init): add --refresh flag for project re-registration
When new projects are added to the config file, `lore sync` doesn't pick them up because project discovery only happens during `lore init`. Previously, users had to use `--force` to overwrite their entire config. The new `--refresh` flag reads the existing config and updates the database to match, without modifying the config file itself. Features: - Validates GitLab authentication before processing - Registers new projects from config into the database - Detects orphan projects (in DB but removed from config) - Interactive mode: prompts to delete orphans (default: No) - Robot mode: returns JSON with orphan info, no prompts Usage: lore init --refresh # Interactive lore --robot init --refresh # JSON output Improved UX: When running `lore init` with an existing config and no flags, the error message now suggests using `--refresh` to register new projects or `--force` to overwrite the config file. Implementation: - Added RefreshOptions and RefreshResult types to init module - Added run_init_refresh() for core refresh logic - Added delete_orphan_projects() helper for orphan cleanup - Added handle_init_refresh() in main.rs for CLI handling - Added JSON output types for robot mode - Registered --refresh in autocorrect.rs command flags registry - --refresh conflicts with --force (mutually exclusive)
This commit is contained in:
@@ -163,10 +163,15 @@ pub enum Commands {
|
||||
/// Initialize configuration and database
|
||||
#[command(after_help = "\x1b[1mExamples:\x1b[0m
|
||||
lore init # Interactive setup
|
||||
lore init --refresh # Register projects from existing config
|
||||
lore init --force # Overwrite existing config
|
||||
lore --robot init --gitlab-url https://gitlab.com \\
|
||||
--token-env-var GITLAB_TOKEN --projects group/repo # Non-interactive setup")]
|
||||
Init {
|
||||
/// Re-read config and register any new projects in the database
|
||||
#[arg(long, conflicts_with = "force")]
|
||||
refresh: bool,
|
||||
|
||||
/// Skip overwrite confirmation
|
||||
#[arg(short = 'f', long)]
|
||||
force: bool,
|
||||
|
||||
Reference in New Issue
Block a user