Skip to content

Commit

Permalink
Merge branch 'main' into fix-more-parser-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AucaCoyan committed Mar 15, 2024
2 parents 5b65eb3 + 878bfc6 commit 1297a36
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 124 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
pull_request:

env:
NUSHELL_CARGO_PROFILE: ci
NU_LOG_LEVEL: DEBUG

jobs:
nu-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: "Fetch main branch"
run: |
git fetch origin main --depth 1
- uses: hustcer/[email protected]
with:
version: "*"
check-latest: true
features: full # dataframe and extra included
- name: toolkit check pr
shell: nu {0}
# nix STUB_IDE_CHECK when nushell/nushell#12208 fixed
run: |
use ${{ github.workspace }}/toolkit.nu *
STUB_IDE_CHECK=true check pr --and-exit
31 changes: 31 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- main
schedule:
- cron: "30 0 * * *" # every day at 00:30 AM UTC

env:
NUSHELL_CARGO_PROFILE: ci
NU_LOG_LEVEL: DEBUG

jobs:
nu-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: "Fetch main branch"
run: |
git fetch origin main --depth 1
- uses: hustcer/[email protected]
with:
version: "*"
check-latest: true
features: full # dataframe and extra included
- name: toolkit check pr --full
shell: nu {0}
# nix STUB_IDE_CHECK when nushell/nushell#12208 fixed
run: |
use ${{ github.workspace }}/toolkit.nu *
STUB_IDE_CHECK=true check pr --full --and-exit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

# ignore the git mailmap file
.mailmap

check-files.nu
6 changes: 6 additions & 0 deletions aliases/chezmoi/chezmoi-aliases.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export alias ch = chezmoi
export alias chad = chezmoi add
export alias chap = chezmoi apply
export alias chd = chezmoi diff
export alias chda = chezmoi data
export alias chs = chezmoi status
41 changes: 41 additions & 0 deletions custom-completions/flutter/flutter-completions.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export extern "flutter" [
command?: string@"nu-complete flutter commands"
--help(-h) # Print this usage information.
--verbose(-v) # Noisy logging, including all shell commands executed.
--device-id(-d) # Target device id or name (prefixes allowed).
--version # Reports the version of this tool.
--enable-analytics # Enable telemetry reporting each time a flutter or dart command runs.
--disable-analytics # Disable telemetry reporting each time a flutter or dart command runs, until it is re-enabled.
--suppress-analytics # Suppress analytics reporting for the current CLI invocation.
]

def "nu-complete flutter commands" [] {
^flutter --help
| into string
| str replace --regex --multiline '(Manage[\s\S]*(?=Flutter SDK))' ''
| lines
| filter { str starts-with " " }
| each { str trim }
| parse "{value} {description}"
| str trim
}

export extern "flutter create" [
project: string # project to create
]

export extern "flutter pub" [
command?: string@"nu-complete pub commands"
]

def "nu-complete pub commands" [] {
^flutter pub --help
| into string
| str replace --regex --multiline '(Commands[\s\S]*(?=Available subcommands))' ''
| lines
| filter { str starts-with " " }
| each { str trim }
| parse "{value} {description}"
| str trim
}

60 changes: 30 additions & 30 deletions modules/docker/docker.nu
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export def container-list [
# list images
export def image-list [
-n: string@"nu-complete docker ns"
img?: string@"nu-complete docker images"
image?: string@"nu-complete docker images"
] {
if ($img | is-empty) {
if ($image | is-empty) {
^$env.docker-cli ...($n | with-flag -n) images
| from ssv -a
| each {|x|
Expand All @@ -99,7 +99,7 @@ export def image-list [
}
}
} else {
let r = ^$env.docker-cli ...($n | with-flag -n) inspect $img
let r = ^$env.docker-cli ...($n | with-flag -n) inspect $image
| from json
| get 0
let e = $r.Config.Env?
Expand Down Expand Up @@ -170,48 +170,48 @@ def "nu-complete docker images" [] {

# container log
export def container-log [
ctn: string@"nu-complete docker containers"
container: string@"nu-complete docker containers"
-l: int = 100 # line
-n: string@"nu-complete docker ns" # namespace
] {
let l = if $l == 0 { [] } else { [--tail $l] }
^$env.docker-cli ...($n | with-flag -n) logs -f ...$l $ctn
^$env.docker-cli ...($n | with-flag -n) logs -f ...$l $container
}

export def container-log-trunc [
ctn: string@"nu-complete docker containers"
container: string@"nu-complete docker containers"
-n: string@"nu-complete docker ns" # namespace
] {
if $env.docker-cli == 'podman' {
print -e $'(ansi yellow)podman(ansi dark_gray) isn’t supported(ansi reset)'
} else {
let f = ^$env.docker-cli ...($n | with-flag -n) inspect --format='{{.LogPath}}' $ctn
let f = ^$env.docker-cli ...($n | with-flag -n) inspect --format='{{.LogPath}}' $container
truncate -s 0 $f
}
}

# attach container
export def --wrapped container-attach [
ctn: string@"nu-complete docker containers"
container: string@"nu-complete docker containers"
-n: string@"nu-complete docker ns"
...args
] {
let ns = $n | with-flag -n
if ($args|is-empty) {
^$env.docker-cli ...$ns exec -it $ctn /bin/sh -c "[ -e /bin/zsh ] && /bin/zsh || [ -e /bin/bash ] && /bin/bash || /bin/sh"
^$env.docker-cli ...$ns exec -it $container /bin/sh -c "[ -e /bin/zsh ] && /bin/zsh || [ -e /bin/bash ] && /bin/bash || /bin/sh"
} else {
^$env.docker-cli ...$ns exec -it $ctn ...$args
^$env.docker-cli ...$ns exec -it $container ...$args
}
}

def "nu-complete docker cp" [cmd: string, offset: int] {
let argv = $cmd | str substring ..$offset | split row ' '
let p = if ($argv | length) > 2 { $argv | get 2 } else { $argv | get 1 }
let ctn = ^$env.docker-cli ps
let container = ^$env.docker-cli ps
| from ssv -a
| each {|x| {description: $x.'CONTAINER ID' value: $"($x.NAMES):" }}
let n = $p | split row ':'
if $"($n | get 0):" in ($ctn | get value) {
if $"($n | get 0):" in ($container | get value) {
^$env.docker-cli exec ($n | get 0) sh -c $"ls -dp ($n | get 1)*"
| lines
| each {|x| $"($n | get 0):($x)"}
Expand All @@ -220,7 +220,7 @@ def "nu-complete docker cp" [cmd: string, offset: int] {
ls -a ($"($p)*" | into glob)
| each {|x| if $x.type == dir { $"($x.name)/"} else { $x.name }}
}
$files | append $ctn
$files | append $container
}
}

Expand All @@ -233,20 +233,20 @@ export def container-copy-file [
}

# remove container
export def container-remove [ctn: string@"nu-complete docker containers" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) container rm -f $ctn
export def container-remove [container: string@"nu-complete docker containers" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) container rm -f $container
}


# history
export def container-history [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) history --no-trunc $img | from ssv -a
export def container-history [image: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) history --no-trunc $image | from ssv -a
}


# save images
export def image-save [-n: string@"nu-complete docker ns" ...img: string@"nu-complete docker images"] {
^$env.docker-cli ...($n | with-flag -n) save ...$img
export def image-save [-n: string@"nu-complete docker ns" ...image: string@"nu-complete docker images"] {
^$env.docker-cli ...($n | with-flag -n) save ...$image
}

# load images
Expand All @@ -265,8 +265,8 @@ export def system-prune-all [-n: string@"nu-complete docker ns"] {
}

# remove image
export def image-remove [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) rmi $img
export def image-remove [image: string@"nu-complete docker images" -n: string@"nu-complete docker ns"] {
^$env.docker-cli ...($n | with-flag -n) rmi $image
}

# add new tag
Expand All @@ -276,15 +276,15 @@ export def image-tag [from: string@"nu-complete docker images" to: string -n: s

# push image
export def image-push [
img: string@"nu-complete docker images"
image: string@"nu-complete docker images"
--tag(-t): string
-n: string@"nu-complete docker ns" -i
] {
let $insecure = if $i {[--insecure-registry]} else {[]}
if ($tag | is-empty) {
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $image
} else {
^$env.docker-cli ...($n | with-flag -n) tag $img $tag
^$env.docker-cli ...($n | with-flag -n) tag $image $tag
do -i {
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $tag
}
Expand All @@ -293,9 +293,9 @@ export def image-push [
}

# pull image
export def image-pull [img -n: string@"nu-complete docker ns" -i] {
export def image-pull [image -n: string@"nu-complete docker ns" -i] {
let $insecure = if $i {[--insecure-registry]} else {[]}
^$env.docker-cli ...($n | with-flag -n) ...$insecure pull $img
^$env.docker-cli ...($n | with-flag -n) ...$insecure pull $image
}

### list volume
Expand Down Expand Up @@ -371,7 +371,7 @@ export def container-create [
--with-x
--privileged(-P)
--namespace(-n): string@"nu-complete docker ns"
img: string@"nu-complete docker images" # image
image: string@"nu-complete docker images" # image
...cmd # command args
] {
let ns = $namespace | with-flag -n
Expand Down Expand Up @@ -409,11 +409,11 @@ export def container-create [
$debug $appimage $netadmin $with_x
$mnt $vols $workdir $cache
] | flatten
let name = $"($img | split row '/' | last | str replace ':' '-')_(date now | format date %m%d%H%M)"
let name = $"($image | split row '/' | last | str replace ':' '-')_(date now | format date %m%d%H%M)"
if $dry_run {
echo ([docker $ns run --name $name $args $img $cmd] | flatten | str join ' ')
echo ([docker $ns run --name $name $args $image $cmd] | flatten | str join ' ')
} else {
^$env.docker-cli ...$ns run --name $name ...$args $img ...($cmd | flatten)
^$env.docker-cli ...$ns run --name $name ...$args $image ...($cmd | flatten)
}
}

Expand Down
8 changes: 4 additions & 4 deletions modules/git/git-v2.nu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ../argx/argx.nu
use argx.nu

def agree [
prompt
Expand Down Expand Up @@ -119,7 +119,7 @@ export def gb [
} else if ($branch | is-empty) {
let merged = git branch --merged
| lines
| each { $in | parse -r '\s*\*?\s*(?P<b>[^\s]+)' | get 0.b }
| each { $in | parse -r '\s*\*?\s*(?<b>[^\s]+)' | get 0.b }
{
local: (git branch)
remote: (git branch --remote)
Expand All @@ -128,7 +128,7 @@ export def gb [
| each {|x|
$x.v | lines
| each {|n|
let n = $n | parse -r '\s*(?P<c>\*)?\s*(?P<b>[^\s]+)( -> )?(?P<r>[^\s]+)?' | get 0
let n = $n | parse -r '\s*(?<c>\*)?\s*(?<b>[^\s]+)( -> )?(?<r>[^\s]+)?' | get 0
let c = if ($n.c | is-empty) { null } else { true }
let r = if ($n.r | is-empty) { null } else { $n.r }
let m = if $n.b in $merged { true } else { null }
Expand Down Expand Up @@ -595,7 +595,7 @@ export def _git_log_stat [n] {
| split row ','
| each {|x| $x
| str trim
| parse -r "(?P<num>[0-9]+) (?P<col>.+)"
| parse -r "(?<num>[0-9]+) (?<col>.+)"
| get 0
}
| reduce -f {sha: $acc.c file:0 ins:0 del:0} {|i,a|
Expand Down
Loading

0 comments on commit 1297a36

Please sign in to comment.