feat(nushell): gate cache clone behind update flag
- only clone missing nu_scripts cache when using -u/-f - keep default pj completion as non-cloning check mode - align completion flag help text with new behavior
This commit is contained in:
@@ -55,8 +55,8 @@ def _pj_completion_registry_lines [] {
|
|||||||
|
|
||||||
def _pj_completion_help [] {
|
def _pj_completion_help [] {
|
||||||
print "pj completion commands:"
|
print "pj completion commands:"
|
||||||
print " pj completion Clone/update cache and check required completion files."
|
print " pj completion Check required completion files from existing cache."
|
||||||
print " pj completion -u Update cached nu_scripts repository."
|
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 -f Force re-clone cached nu_scripts repository."
|
||||||
print " pj completion sync Regenerate cache registry and restart Nushell."
|
print " pj completion sync Regenerate cache registry and restart Nushell."
|
||||||
print " pj completion -s Same as `pj completion sync`."
|
print " pj completion -s Same as `pj completion sync`."
|
||||||
@@ -80,8 +80,8 @@ export def "pj completion sync" [
|
|||||||
}
|
}
|
||||||
|
|
||||||
export def "pj completion" [
|
export def "pj completion" [
|
||||||
--update(-u) # Pull latest changes when repo already exists.
|
--update(-u) # Update cached repo, or clone when cache is missing.
|
||||||
--force(-f) # Re-clone even when repo already exists.
|
--force(-f) # Force re-clone cached nu_scripts repository.
|
||||||
--sync(-s) # Regenerate static registry and restart Nushell.
|
--sync(-s) # Regenerate static registry and restart Nushell.
|
||||||
--help(-h) # Show help.
|
--help(-h) # Show help.
|
||||||
] {
|
] {
|
||||||
@@ -120,8 +120,19 @@ export def "pj completion" [
|
|||||||
}
|
}
|
||||||
|
|
||||||
if not ($repo_dir | path exists) {
|
if not ($repo_dir | path exists) {
|
||||||
print "[pj completion] nu_scripts cache not found, cloning..."
|
if ($update or $force) {
|
||||||
^git clone $repo_url $repo_dir
|
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 {
|
} else {
|
||||||
if not (($repo_dir | path join '.git') | path exists) {
|
if not (($repo_dir | path join '.git') | path exists) {
|
||||||
print "[pj completion] existing cache is not a git repo, re-cloning..."
|
print "[pj completion] existing cache is not a git repo, re-cloning..."
|
||||||
|
|||||||
Reference in New Issue
Block a user