Skip to content

Commit 1b0d707

Browse files
authored
feat(nushell): add support for “org/repo” syntax in ghrepoclone command (#245)
1 parent 4f1b70c commit 1b0d707

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nushell/init.nu

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,21 @@ def ghrepoclone [
175175
--folder (-f) = ""
176176
--open = true
177177
] {
178-
let repoWithOwner = ([$org, $repo] | path join)
178+
let parsed = if ($repo | str contains "/") {
179+
let parts = ($repo | split row "/")
180+
{ org: ($parts | first), repo: ($parts | last) }
181+
} else {
182+
{ org: $org, repo: $repo }
183+
}
184+
185+
let repoWithOwner = ([$parsed.org, $parsed.repo] | path join)
179186
let target = ([$folder, $repoWithOwner] | where ($it != "") | first)
180187
let directory = ([$nu.home-dir "Documents/dev" $target] | path join)
181188

182189
if ($directory | path exists) {
183190
print $"Directory ($directory) already exists"
184191
} else {
185-
gh repo clone $"($org)/($repo)" $directory
192+
gh repo clone $"($parsed.org)/($parsed.repo)" $directory
186193
}
187194

188195
if ($open) {

0 commit comments

Comments
 (0)