Commit Graph

903 Commits

Author SHA1 Message Date
Stefan Holderbach
b9c873bc67
Remove the failing CI on the main branch (#805)
See
https://github.com/nushell/nu_scripts/pull/771#issuecomment-2020331739
and following

As we don't have a path forward to make sure all files are fixed and
will be maintained. (and the file detection itself is reliable)
Disable the `main` branch (and nightly run) for now.

This will keep the CI for PRs so at least added scripts pass the current
nu version
2024-03-30 16:37:19 -05:00
Texas Toland
268201e4ac
[stdlib-candidate] Clean up file bulk-rename a little (#798)
[Generated diff](https://www.diffnow.com/report/xmq4f) for command
because move broke it.

- No `file` prefix similar to other [filesystem
commands](https://www.nushell.sh/commands/categories/filesystem.html)
- Input paths instead of directory param for filters or globbing
- Record closure param with original path (`$in` is still stem)
- `--verbose` table output
- `--no-exectute` for dry run with `--verbose`
- Shorthand flags
- Parallel renaming for large directories
- More tests

@amtoine Request feedback 🙏🏼 Happy to revise ot revert anything!

```console
❯ bulk-rename -h
Rename bulk input files in parallel using a closure.

The reason behind this command is quite simple:
- Sometimes one receives a bunch of files with integer ids: 1, 2, 3, ...
- These ids come rarely with padding... i.e. 1 instead of 001 when there are 3-digit ids
- This means that file with id 9 will be sorted way after file with id 1000

This command allows to do such a task!

Examples:
  Rename `.mise.toml` files to `.mise.local.toml` recursively
  > glob **/.mise.toml | bulk-rename { str append .local }

  Rename files in `/foo` with a name that has an id to have 3 digits with 0-padding
  > ls /foo | bulk-rename { |path|
     if $path.input.type == file {
       $path.stem | parse "some_format_{id}"
         | get 0
         | update id { fill --alignment r --character 0 --width 3 }
         | $"some_format_($in.id)"
     }
     # else skip dirs
   }

Usage:
  > main {flags} <update_stem>

Flags:
  -v, --verbose - Show which files were renamed, if any
  -n, --no-execute - Do not make any changes; add --verbose to see what would be made
whitespace bug: nushell/nushell#12264
  -h, --help - Display the help message for this command

Parameters:
  update_stem <closure()>: The code to rename the file stem: receives the old stem as input and a record param with both `stem` and `input` keys

Input/output types:
  ╭───┬───────────┬─────────────────────────────────╮
  │ # │   input   │             output              │
  ├───┼───────────┼─────────────────────────────────┤
  │ 0 │ list<any> │ nothing                         │
  │ 1 │ list<any> │ table<old: string, new: string> │
  ╰───┴───────────┴─────────────────────────────────╯
```
2024-03-30 16:19:06 -05:00
fj0r
f39976902a
kube refine for backup (#793)
- new function `kube refine`
- define the required information in `$env.KUBERNETES_REFINE`, `kube
refine` will collect information according to its definition
- definitions in `status` and `cluster_status` are runtime information
and will not be collected. They are used in the `kg` command to display
status
- normalize the output of the `kg`, `kgp`, `kgs` command using `krefine`

- rename `kcconf` to `kccc` (kubectl change context clone)

- a new module, `refine.nu`, declaratively extracts data from complex
structures.

- `container-list` additionally displays the cmd field of the image

---------

Co-authored-by: nash <nash@iffy.me>
2024-03-30 07:14:45 -05:00
Auca Coyan
ea56f42e76
add gh gist and gh repo list and view (#803)
moar commands to `gh` CLI
2024-03-28 06:40:45 -05:00
Auca Coyan
0713693906
add rye completions (#802)
completions to `rye`
2024-03-27 18:36:51 -05:00
Enzo Einhorn
41fe58ecee
Add Micromamba support (#800)
I initially tried to get Micromamba to work with Nushell by using the
script from [this
issue](https://github.com/nushell/nu_scripts/issues/578). But even after
fixing the syntax errors I couldn't activate any env.
With these modifications, Micromamba seems to be working fine.  
Please note that I'm far from a Nu expert so my code might not be very
idiomatic. If that is the case please tell me so and I'll be happy to do
the necessary changes.
2024-03-26 13:47:45 -05:00
Róbert Kalmár
3cee758551
Fix git branch cleanup for nushell version 0.91+ (#799) 2024-03-26 07:24:40 -05:00
Texas Toland
707cda3450
Clean up str append/prepend a little (#797)
- Move to directory for other `str` contributions
- Add simple `help` docs
- Simplify type check since only 2 cases are possible

@savente93 Are these okay?
2024-03-20 10:46:12 -05:00
Auca Coyan
7d662ad5c5
add gh gist and gh repo list and view (#794)
A bit more of `gh` completions
2024-03-17 07:15:15 -05:00
Texas Toland
cf88c11509
Refactor stdlib-candidate for nupm (#790)
Easier to review individual commits because of renames. Happy to provide
DiffNow links if helpful. Involved:

1. Moving scripts to a subdirectory
2. Copying `nupm.nuon` from another directory
3. Making modules work
4. Extracting tests
5. Fixing tests (related to nushell/nushell#12193)

To test first set up nupm then:

```console
nu_scripts on  std-nupm-integration
❯ $env.NUPM_REGISTRIES.nupm_test = 'https://raw.githubusercontent.com/texastoland/nupm/registry-std-rfc/registry.nuon'

nu_scripts on  std-nupm-integration
❯ nupm install std-rfc
╭──────────┬───────────────────────────────────────────╮
│ name     │ std-rfc                                   │
│ version  │ 0.1.0                                     │
│ url      │ https://github.com/texastoland/nu_scripts │
│ revision │ 65aa7cc                                   │
│ path     │ stdlib-candidate                          │
│ type     │ git                                       │
╰──────────┴───────────────────────────────────────────╯
Cloning into 'nu_scripts-4a047f13a05fe35393f3a8d73377b02c-65aa7cc'...
remote: Enumerating objects: 8015, done.
remote: Counting objects: 100% (822/822), done.
remote: Compressing objects: 100% (333/333), done.
remote: Total 8015 (delta 538), reused 641 (delta 445), pack-reused 7193
Receiving objects: 100% (8015/8015), 49.72 MiB | 23.12 MiB/s, done.
Resolving deltas: 100% (4605/4605), done.
Note: switching to '65aa7cc'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 65aa7cc Fix nupm test --dir stdlib-candidate
2024-03-12T20:42:49.462|INF|installing package std-rfc

nu_scripts on  std-nupm-integration took 4s
❯ use std-rfc set-env

nu_scripts on  std-nupm-integration
❯ set-env -h
Gracefully set an environment variable or merge a nested option.
...etc.

nu_scripts on  std-nupm-integration
❯ nupm test --dir stdlib-candidate
Testing package /Users/texas/Developer/nu_scripts/stdlib-candidate
tests record filter-name predicate ... SUCCESS
tests record filter-value predicate ... SUCCESS
tests record list_merge ... SUCCESS
tests str append ... SUCCESS
tests fs file bulk-rename ... SUCCESS
tests str prepend ... SUCCESS
tests record filter-name text ... SUCCESS
Ran 7 tests. 7 succeeded, 0 failed.
```
2024-03-16 13:57:05 +02:00
Auca Coyan
13a73ab635
🐛 fix more parser errors (#783)
Hi! I reduced some of the errors in the daily CI. Still there are a few
of them, but at least is something

- Added the badge for the `daily.yml` (currently failing)
- removed old `docker` from v0.60
- removed old `git` from auto-generate completions
- removed `nethack` from auto-generate completions (wasn't very useful)
- removed `root` from auto-generate completions (wasn't very useful)
- removed `valgrind` from auto-generate completions (wasn't very useful)
- moved `less` from auto-generate to custom-completions.
- moved `mix` from auto-generate to custom-completions.
- moved `tar` from auto-generate to custom-completions.
- moved `tcpdump` from auto-generate to custom-completions.
- moved `virsh` from auto-generate to custom-completions.
- moved `zef` from auto-generate to custom-completions.
- fixed `base16.nu`
- fixed `from-cpuinfo.nu`
- fixed `from-dmicode.nu`
- fixed `to-number-format.nu`
- fixed `to-json-schema.nu`
2024-03-15 21:10:27 -05:00
Texas Toland
878bfc615c
Refactor toolkit.nu (#791)
Closes #789 🍻

- Runs without first generating a script
- Returns error (file) count
- Requires `--and-exit` to exit with error code
- Enables alternative report with env `STUB_IDE_CHECK=true`
- Expands documentation
- All subcommands share same file querying
- Prepares for nupm test integration
2024-03-15 19:17:31 +02:00
Auca Coyan
191636af9c
add flutter completions (#792)
Just a barebones `flutter` command and `flutter pub` commands, the most
used ones
2024-03-15 06:30:31 -05:00
Auca Coyan
c2ef662e48
add a nu-check verification CI (#771)
I made a `toolkit.nu` with a very bare bones struct, this is called via
[`setup-nu`](https://github.com/hustcer/setup-nu) action, and generates
the `check-files.nu` file. After that, another nu instance run that
script to check files one by one. The folder `before_v0.60/` is
excluded.
2024-03-12 20:48:08 +01:00
fnuttens
45f5310e51
Add chezmoi aliases (#788) 2024-03-12 10:55:37 -05:00
Texas Toland
74ba060f55
[stdlib-candidate] set-env (#787)
Rewrite of nushell/nushell#12156 for jdx/mise#1763.

### Why?

Nushell philosophically omits a `set` list mutation. But `$env` is
inherently mutable leading to issues described in nushell/nushell#12148.
`set-env` provides such an operation exclusively for `$env`.

### What changed?

1. Explicit flag instead of implicit list concatenation
2. Expands updates to any `$env` field not only `$env.config`

### How is it used?

```yaml
❯ set-env -h
Gracefully set an environment variable or merge a nested option.

Examples:
  Set $env.NUPM_HOME
  > set-env NUPM_HOME $'($nu.home-path)/.local/share/nupm'

  Add to $env.NU_LIB_DIRS
  > set-env --append NU_LIB_DIRS $'($env.NUPM_HOME)/modules'

  Set a nested config option
  > set-env config.filesize.metric true

  Add a config hook
  > set-env -a config.hooks.pre_prompt 'ellie | print'

Usage:
  > main {flags} <field> <value>

Flags:
  -a, --append - Append to the previous value or wrap in a new list
  -h, --help - Display the help message for this command

Parameters:
  field <cell-path>: The environment variable name or nested option cell path
  value <any>: The value to set or append

Input/output types:
  ╭───┬─────────┬─────────╮
  │ # │  input  │ output  │
  ├───┼─────────┼─────────┤
  │ 0 │ nothing │ nothing │
  ╰───┴─────────┴─────────╯
```

### How does it work?

```nushell
export def --env main [
  field: cell-path
  value: any
  --append (-a)
]: nothing -> nothing {

  # just an alias
  def 'get or' [default field] {
    get --ignore-errors $field | default $default
  }

  let value = if $append {
    # append to the previous value or empty list
    $env | get or [] $field | append $value
  } else {
    $value
  }

  # work around nushell/nushell#12168
  let field = $field | to text | split row .
  let value = match $field {

    [_] => $value
    # if cell path is nested
    [$root, ..$field] => {
      let field = $field | into cell-path

      # reassigning $env would be an error
      # merging reserved names like PWD would be an error
      # so merge from 1 level deep instead
      $env | get or {} $root | upsert $field $value
    }
  }

  # avoid issues noted above
  load-env { ($field | first): $value }
}
```

### Where are the tests?

Pending next PR for nupm integration.
2024-03-12 10:55:07 -05:00
fj0r
56fe4b94ff
standardized parameter naming for --help and fix regex capture (#786)
standardized parameter naming for `--help`
|old|new|
|-|-|
|img|image|
|ctn|container|
|p|file|
|ctx|context|
|ns|namespace|
|k|kind|
|r, i|resource|
|r|pod, service, deployment|
|res|kind|
|svc|service|
|d, dpl|deployment|

change `(?P<name>)` to `(?<name>)`

Co-authored-by: nash <nash@iffy.me>
2024-03-12 06:45:50 -05:00
neur1n
7fcbf543db
fix: update modules/virtual_environments/nu_msvs to work with nushell 0.91.0 (#784)
Fixed the `glob` related code as mentioned in title.
2024-03-10 21:25:44 -05:00
Auca Coyan
bc6273d971
🐛 fix a couple of parser errors (#782)
This is some legwork to the CI
- [x] fix one `get-row.nu` before 0.60, just because it was easy
- [x] `modules/formats/to-ini.nu`
- [x] `modules/git/git-v2.nu`
- [x] `modules/git/git.nu`
- [x] `modules/log/log.nu`
- [x] `modules/weather/weatherdark.nu`
- [x] `sourced/api_wrappers/worlframalpha.nu`
- [x] `sourced/cool-oneliners/pwd-short.nu`
- [x] `sourced/github/branch-protections/branch-protections.nu`
- [x] `sourced/gitlab/gitlab.nu`
- [x] `sourced/misc/nu_defs.nu`
- [x] `sourced/update-path.nu`
- [x] `sourced/webscraping/shell_starts.nu`
I moved some auto-generated commands:
- [x] `ack` 
- [x] `as`
- [x] `curl`
- [x] `fsarprc`
- [x] `fsarpri`
- [x] `godoc`
- [x] `mysql` 
- [x] and `xgettext` 
to custom, so we keep the modifications.
I had to comment some of the flags because the parser is not able to
parse some flags. Those are explained in comments
2024-03-10 14:05:01 -05:00
Auca Coyan
1ccc379f38
clone all script (#781)
Hi! I did a script to clone multiple repos of github in a single folder
I clone everything I intend to work when I reset my pc

Instructions incluided!
2024-03-10 07:11:37 -05:00
Auca Coyan
5e51b23b1f
🐛 fix scoop completinos (an extra ) (#780)
Just deleting the extra `)`
2024-03-09 13:42:11 +01:00
fj0r
6d98fee3ba
nu-complete docker containers: show all containers (#778)
- use `!` tag failed containers
- if there are duplicate names, the id comes first.

---------

Co-authored-by: nash <nash@iffy.me>
2024-03-08 06:10:46 -06:00
Stefan Holderbach
8a2dcf6cf8
Add option list-merged-pr --table (#774)
Paint a table like one of ~~our French Guys~~ those Amtoine created for
the overview of the hall of fame
2024-03-07 06:19:29 -06:00
Alexis Praga
74f23a4980
Support for catppuccin-latte (#741)
Complete the support for catppucin-mocha.

It looks like there's work for a better way to manage that (
https://github.com/catppuccin/catppuccin/discussions/2140 ) but this can
help other people.
2024-03-07 06:18:50 -06:00
fj0r
43880c91ac
gb -d without arguments cleans branches (#777)
- `gb -d` cleans branches that meet the criteria, if no arguments
  - not current
  - merged
  - `gb -d --no-merged` includes no merged branches
- `gb` (no arguments) output `merged` instead of `no-merged`
- changed `$remote` of `gb` and `gp` to flag
- `remote_branches` return 'remote/branch'

Co-authored-by: nash <nash@iffy.me>
2024-03-06 21:10:45 -06:00
fj0r
0fd766871f
upgrade to 0.91 (#776)
update argx.nu, docker.nu, git-v2.nu, kubernetes.nu, ssh.nu, and nvim.nu
to support 0.91 syntax.

---------

Co-authored-by: nash <nash@iffy.me>
2024-03-06 06:08:26 -06:00
Jakub Žádník
351691f118
Allow listing merged PRs by milestone (#773)
Also changes `date?` parameter to `--date` and slight code refactoring
2024-03-05 21:27:30 +01:00
Jakub Žádník
bccdab661a
Reorder release dependencies (#754)
These are the changes after running nu_deps
2024-03-05 21:27:04 +01:00
Shen Zhou
25514da84d
fix: output format changed in zellij ls (#770)
Hi. In the latest zellij (0.39.2), the output of `zellij ls` has been
changed into the following example:
```bash
rectangular-galaxy [Created 9h 21m 46s ago] (EXITED - attach to resurrect)
gregarious-triceratops [Created 22h 48m 32s ago] (EXITED - attach to resurrect)
```
I updated the corresponding parsing code.
2024-03-02 07:42:34 -06:00
Auca Coyan
a60debf624
add cargo-make completions (#769)
Hi! I added cargo make completions 😄 


![image](https://github.com/nushell/nu_scripts/assets/30557287/8d8d64e8-82a7-4d20-8879-f401a00bf6f5)
2024-02-29 14:23:17 -06:00
fj0r
a31696ea2a
Rename edit to nve to avoid potential conflicts (#768)
- rename `edit` to `nve` to avoid potential conflicts
- `e`, `c`, `v`, `x` export as alias
- nested nvim creates new buffer when no filename as args
- `cwdhist` use Alt+o as default

Co-authored-by: nash <nash@iffy.me>
2024-02-29 06:32:19 -06:00
Auca Coyan
f6bbfe5b77
add rg completions (#767)
I added a lot, but not all the `rg` flags. Currently there are 107 and
most of them aren't "results" related, but compatibility for terminals,
negate previous flags when searching multiple regexes and more.
I selected the most useful flags and write them down in the file.
I accept any suggestion!
2024-02-28 14:14:19 -06:00
Auca Coyan
9fcd386aff
add bat completions (#766)
I use it _all the time_!
I am on my way to `rg` completions too, I use it about as often as `bat`
2024-02-28 09:45:46 -06:00
Auca Coyan
6585a0f515
🐛 fix optional arg in git stash show (#765)
Hi! Another bug I found, in `git`, you can
```bash
git stash show
```
with no args and should be alright, but the .nu script is requiring a
git name. (maybe for a previous version of git it was needed)
2024-02-26 15:42:28 -06:00
fj0r
d177037ed2
merge nvdc into nvc (#764)
use a unified nvc to start the neovim client, and then have a flag --gui
to start the neovim gui program.
And collect some common GUI startup methods, detect which one exists and
start which one.

---------

Co-authored-by: nash <nash@iffy.me>
2024-02-25 08:42:14 -06:00
fj0r
da6fb3e800
add gig --empty-dir (#762)
upgrade nvdc for neovide

---------

Co-authored-by: nash <nash@iffy.me>
2024-02-25 07:46:28 -06:00
Auca Coyan
6309a9f29b
🐛 fix optional args when doing gh repo create and gh repo fork (#763)
Hi!
I found another bug, if you write
```bash
$ gh repo create
```
it leads you to a series of prompts, but the current nu script throws an
error.
I fixed that and `gh repo fork` too, in which you don't necessarily need
an argument.
2024-02-22 13:19:55 -06:00
fj0r
144f3fefde
new cmd: container-log-trunc (#761)
clean container-log-namespace

Co-authored-by: nash <nash@iffy.me>
2024-02-20 06:33:12 -06:00
fj0r
e8f4d7462a
ksi: kubectl set image (#760)
Co-authored-by: nash <nash@iffy.me>
2024-02-20 06:32:46 -06:00
Antoine Stevan
f04cb445e4
rename package files (#701)
related to
- https://github.com/nushell/nupm/pull/51

depends on
- https://github.com/nushell/nu_scripts/pull/700

> **Important**
> this PR will be rebased once #700 lands and only
a5a6b6f950
is relevant here

## description
this is a simple rename of `package.nuon` files to `nupm.nuon` as per
https://github.com/nushell/nupm/pull/51.
2024-02-18 16:23:47 +01:00
Antoine Stevan
4180ce853c
split the package into nu-themes and nu-hooks (#700)
related to 
- https://github.com/nushell/nupm/pull/50

## description
`nu-scripts` was not really a package but rather a set of two module
packages.
this feature has been removed from Nupm in
https://github.com/nushell/nupm/pull/50 and this PR fixes the
`nu-scripts` packages.

> **Note**
> the files in `nu-hooks/` have been moved to `nu-hooks/nu-hooks/` to
fit into the current model of Nupm

this PR does not change anything from the user point of view, apart from
the install that goes from
```nushell
nupm install --path --force .
```
to
```nushell
for pkg in (ls **/package.nuon | get name | path dirname) {
    nupm install --force --path $pkg
}
```
2024-02-18 16:21:35 +01:00
fj0r
7025edf6d6
fix container-create (#759)
Co-authored-by: nash <nash@iffy.me>
2024-02-17 09:02:24 -06:00
John Olheiser
36dcb7ccf2
fix: update deprecated spread operator in just (#758) 2024-02-10 16:23:30 -06:00
Martin Wurm
dbf4586594
Extend pass completion (#756)
This PR extends the existing completion for the pass command to include
all existing subcommands (as of pass v1.7.4). It also adds completions
for the pass-otp and pass-update extensions.
2024-02-07 10:46:41 -06:00
Róbert Kalmár
c8c29728d8
Add refs to git log output (#757)
This PR adds the list of references on a commit for the `gl` command
2024-02-07 09:11:55 -06:00
Mel Massadian
3f824d3f30
feat: add pixi completions (#755)
Completions for [pixi](https://github.com/prefix-dev/pixi) generated
from the [last commit
(e330e4b831959452b859079f45fdc77e45d741a9)](e330e4b831)
to date using the clap auto generation.
2024-02-07 07:21:36 -06:00
Jakub Žádník
a17186f25f
Add script to generate lists of PRs (#753)
This wraps existing code from @amtoine to auto-generate the PRs for Full
Changelog and Breaking Changes sections.
2024-02-06 22:59:46 +02:00
RGBCube
14e77c7ec8
background_task: Fix quoted commands and fix deprecation of implicit spreading and clarify docs (#752) 2024-02-05 06:28:48 -06:00
fj0r
302fd84fed
image-push supports renaming via -t (#750)
fix nu-complete of `docker registry show`

Co-authored-by: nash <nash@iffy.me>
2024-01-26 06:48:51 -06:00
Auca Coyan
73955cd4cf
🐛 fix winget-completions (#749)
Parser did a good job here, explaining
```
Error:   × Deprecated: --flag: bool
    ╭─[C:\...\nu_scripts\custom-completions\winget\winget-completions.nu:27:1]
 27 │
 28 │ def "nu-complete winget flagify" [name: string, value: any, --short(-s): bool] {
    ·                                                                          ──┬─
    ·                                                                            ╰── `--flag: bool` is deprecated and will be removed in 0.90. Please use `--flag` instead, more info: https://www.nushell.sh/book/custom_commands.html
 29 │   let flag_start = if $short { '-' } else { '--' }
    ╰────
```
is not possible anymore, so I removed all the `: bool`s and sourced the
script correctly!
2024-01-25 11:50:26 -06:00