diff --git a/nushell/modules/pj_completions.nu b/nushell/modules/pj_completions.nu index 8bb317c..1606c38 100644 --- a/nushell/modules/pj_completions.nu +++ b/nushell/modules/pj_completions.nu @@ -55,8 +55,8 @@ def _pj_completion_registry_lines [] { def _pj_completion_help [] { print "pj completion commands:" - print " pj completion Clone/update cache and check required completion files." - print " pj completion -u Update cached nu_scripts repository." + print " pj completion Check required completion files from existing cache." + print " pj completion -u Update cache, or clone nu_scripts when cache is missing." print " pj completion -f Force re-clone cached nu_scripts repository." print " pj completion sync Regenerate cache registry and restart Nushell." print " pj completion -s Same as `pj completion sync`." @@ -80,8 +80,8 @@ export def "pj completion sync" [ } export def "pj completion" [ - --update(-u) # Pull latest changes when repo already exists. - --force(-f) # Re-clone even when repo already exists. + --update(-u) # Update cached repo, or clone when cache is missing. + --force(-f) # Force re-clone cached nu_scripts repository. --sync(-s) # Regenerate static registry and restart Nushell. --help(-h) # Show help. ] { @@ -120,8 +120,19 @@ export def "pj completion" [ } if not ($repo_dir | path exists) { - print "[pj completion] nu_scripts cache not found, cloning..." - ^git clone $repo_url $repo_dir + if ($update or $force) { + print "[pj completion] nu_scripts cache not found, cloning..." + ^git clone $repo_url $repo_dir + } else { + print "[pj completion] nu_scripts cache not found. run `pj completion -u` to clone it." + return { + cache_dir: $cache_dir + repo_dir: $repo_dir + completion_dir: $completion_dir + commands: $pj_completion_commands + missing_files: [] + } + } } else { if not (($repo_dir | path join '.git') | path exists) { print "[pj completion] existing cache is not a git repo, re-cloning..."