chore: move rules to root

This commit is contained in:
iff 2024-12-08 21:13:22 +01:00
parent 79264e1a4e
commit 0c7277f910
18 changed files with 2 additions and 2 deletions

1
core/rules Symbolic link
View file

@ -0,0 +1 @@
../rules

View file

@ -1,17 +0,0 @@
command = "c"
[[match_err]]
pattern = [
"command not found",
"unknown command",
"nu::shell::external_command"
]
suggest = [
'''
#[length(2)]
cd {{command[1:]}} ''',
'''
#[min_length(3)]
cp {{command[1:]}} '''
]

View file

@ -1,12 +0,0 @@
command = "cargo"
[[match_err]]
pattern = [
"no such command"
]
suggest = [
'''
#[err_contains(did you mean)]
{{command[0]}} {{err::(?:did you mean `)(.*)(?:`\?)}} {{command[2:]}} '''
]

View file

@ -1,19 +0,0 @@
command = "cat"
[[match_err]]
pattern = [
"no such file or directory"
]
suggest = [
'''
cat {{typo[1](file)}} '''
]
[[match_err]]
pattern = [
"is a directory"
]
suggest = [
'''
ls {{command[1:]}}'''
]

View file

@ -1,26 +0,0 @@
command = "cd"
[[match_err]]
pattern = [
"no such file or directory",
"does not exist"
]
suggest = [
'''
cd {{typo[1](file)}}
''',
'''
#[!shell(nu)]
mkdir --parents {{command[1]}} && \
cd {{command[1]}} '''
]
[[match_err]]
pattern = [
"nu::shell::directory_not_found"
]
suggest = [
'''
mkdir {{command[1]}} and \
cd {{command[1]}} '''
]

View file

@ -1,22 +0,0 @@
command = "cp"
[[match_err]]
pattern = [
"-r not specified",
]
suggest = [
'''
{{command[0]}} -r {{command[1:]}} '''
]
[[match_err]]
pattern = [
"cannot create directory",
]
suggest = [
'''
#[err_contains(no such file or directory)]
mkdir -p {{cmd::(?m)\s(\S+[\\\/])\S*\s*$}} && \
{{command[0]}} {{opt::\s(-[\w]+)}} {{command[1:]}} '''
]

View file

@ -1,111 +0,0 @@
command = "git"
[[match_err]]
pattern = [
"is not a git command"
]
suggest = [
'''
{{command[0]}} {{typo[1](
add,
am,
archive,
bisect,
branch,
bundle,
checkout,
cherry-pick,
citool,
clean,
clone,
commit,
describe,
diff,
fetch,
format-patch,
gc,
gitk,
grep,
gui,
init,
log,
maintenance,
merge,
mv,
notes,
pull,
push,
range-diff,
rebase,
reset,
restore,
revert,
rm,
scalar,
shortlog,
show,
sparse-checkout,
stash,
status,
submodule,
switch,
tag,
worktree,
config,
fast-export,
fast-import,
filter-branch,
mergetool,
pack-refs,
prune,
reflog,
remote,
repack,
replace,
)}} {{command[2:]}}'''
]
[[match_err]]
pattern = [
"did not match any file"
]
# alternatively `git checkout {{typo[2]({{shell(git branch | sed 's/^*//')}})}}`
suggest = [
'''
#[cmd_contains(checkout)]
git checkout {{typo[2]({{shell(git branch | sed 's/^*//')}})}} ''',
'''
#[cmd_contains(checkout)]
git branch {{command[2]}} && \
git checkout {{command[2]}} '''
]
[[match_err]]
pattern = [
"has no upstream branch"
]
suggest = [
'''
#[cmd_contains(push)]
git push --set-upstream origin {{shell(git rev-parse --abbrev-ref HEAD)}} '''
]
[[match_err]]
pattern = [
"no tracking information for the current branch"
]
suggest = [
'''
#[cmd_contains(pull)]
git pull --set-upstream origin {{shell(git rev-parse --abbrev-ref HEAD)}} '''
]
[[match_err]]
pattern = [
"a branch named"
]
suggest = [
'''
#[cmd_contains(branch)]
git checkout {{command[2]}} '''
]

View file

@ -1,11 +0,0 @@
command = "mkdir"
[[match_err]]
pattern = [
"cannot create directory"
]
suggest = [
'''
#[err_contains(no such file or directory)]
{{command}} --parents '''
]

View file

@ -1,13 +0,0 @@
command = "mv"
[[match_err]]
pattern = [
"no such file or directory",
"not a directory"
]
suggest = [
'''
mkdir --parents {{command[-1]}} && \
{{command}} '''
]

View file

@ -1,78 +0,0 @@
command = "npm"
[[match_err]]
pattern = [
"unknown command"
]
suggest = [
'''
{{command[0]}} {{typo[1](
access,
adduser,
audit,
bugs,
cache,
ci,
completion,
config,
dedupe,
deprecate,
diff,
dist-tag,
docs,
doctor,
edit,
exec,
explain,
explore,
find-dupes,
fund,
get,
help,
help-search,
hook,
init,
install,
install-ci-test,
install-test,
link,
ll,
login,
logout,
ls,
org,
outdated,
owner,
pack,
ping,
pkg,
prefix,
profile,
prune,
publish,
query,
rebuild,
repo,
restart,
root,
run-script,
sbom,
search,
set,
shrinkwrap,
star,
stars,
start,
stop,
team,
test,
token,
uninstall,
unpublish,
unstar,
update,
version,
view,
whoami
)}} {{command[2:]}} '''
]

View file

@ -1,11 +0,0 @@
command = "pacman"
[[match_err]]
pattern = [
"no operation specified"
]
suggest = [
'''
{{command}} -Syu'''
]

View file

@ -1,12 +0,0 @@
command = "_PR_general"
[[match_err]]
pattern = [
"command not found",
"unknown command",
"nu::shell::external_command"
]
suggest = [
'''
{{typo[0](path)}} {{command[1:]}} '''
]

View file

@ -1,37 +0,0 @@
command = "_PR_privilege"
[[match_err]]
pattern = [
"as root",
"authentication is required",
"be root",
"be superuser",
"cannot access",
"eacces",
"edspermissionerror",
"insufficient privileges",
"need root",
"non-root users cannot",
"not super-user",
"only root can",
"operation not permitted",
"permission denied",
"requires root",
"root privilege",
"root user",
"sudorequirederror",
"superuser privilege",
"unless you are root",
"can not open a temporary file",
"use `sudo`",
"you don't have access",
"you don't have write permissions"
]
suggest = [
'''
#[executable(sudo)]
sudo {{command}} ''',
'''
#[executable(doas)]
doas {{command}} '''
]

View file

@ -1,22 +0,0 @@
command = "rm"
[[match_err]]
pattern = [
"is a directory",
"try --recursive"
]
suggest = [
'''
{{command}} --recursive '''
]
[[match_err]]
pattern = [
"no such file or directory",
"file(s) not found"
]
suggest = [
'''
{{command[0}} {{opt::(?:\s)(-[\w]+)}} {{typo[1:](file)}} '''
]

View file

@ -1,17 +0,0 @@
command = "touch"
[[match_err]]
pattern = [ "no such file or directory" ]
suggest = [
'''
mkdir --parents {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}} && \
touch {{command[1:]}} '''
]
[[match_err]]
pattern = [ "nu::shell::create_not_possible" ]
suggest = [
'''
mkdir {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}} and \
touch {{command[1:]}} '''
]

View file

@ -1,64 +0,0 @@
command = "yarn"
[[match_err]]
pattern = [
"not found"
]
suggest = [
'''
#[err_contains(command)]
{{command[0]}} {{typo[1](
access,
add,
audit,
autoclean,
bin,
cache,
check,
config,
create,
exec,
generate-lock-entry,
generateLockEntry,
global,
help,
import,
info,
init,
install,
licenses,
link,
list,
login,
logout,
node,
outdated,
owner,
pack,
policies,
publish,
remove,
run,
tag,
team,
unlink,
unplug,
upgrade,
upgrade-interactive,
upgradeInteractive,
version,
versions,
why,
workspace,
workspaces
)}} {{command[2:]}} '''
]
[[match_err]]
pattern = [
"error `install` has been replaced with `add` to add new dependencies."
]
suggest = [
'''
yarn add {{command[2:]}} '''
]