Compatibilité elvish 0.17
This commit is contained in:
parent
be84588373
commit
87eb82a791
43 changed files with 323 additions and 322 deletions
|
|
@ -1,44 +1,44 @@
|
|||
use str
|
||||
use re
|
||||
|
||||
fn -bytes [begin size]{
|
||||
fn -bytes {|begin size|
|
||||
str:from-codepoints (range $begin (+ $begin $size))
|
||||
}
|
||||
|
||||
fn -upper []{
|
||||
fn -upper {||
|
||||
-bytes 0x41 26
|
||||
}
|
||||
|
||||
fn -lower []{
|
||||
fn -lower {||
|
||||
-bytes 0x61 26
|
||||
}
|
||||
|
||||
fn -digit []{
|
||||
fn -digit {||
|
||||
-bytes 0x30 10
|
||||
}
|
||||
|
||||
fn -j [@strings]{
|
||||
fn -j {|@strings|
|
||||
str:join '' $strings
|
||||
}
|
||||
|
||||
fn -alpha []{
|
||||
fn -alpha {||
|
||||
-j (-upper) (-lower)
|
||||
}
|
||||
|
||||
fn -alphanum []{
|
||||
fn -alphanum {||
|
||||
-j (-alpha) (-digit)
|
||||
}
|
||||
|
||||
fn -random [chars]{
|
||||
fn -random {|chars|
|
||||
var size = (count $chars)
|
||||
print $chars[(randint 0 $size)]
|
||||
}
|
||||
|
||||
fn -is-int [arg]{
|
||||
fn -is-int {|arg|
|
||||
re:match '^\d+$' $arg
|
||||
}
|
||||
|
||||
fn -help []{
|
||||
fn -help {||
|
||||
echo 'Génère une chaîne de caractères aléatoires'
|
||||
echo 'Usage: genstr [(-auldh)] [<chars>] [<size>]'
|
||||
echo ''
|
||||
|
|
@ -54,9 +54,9 @@ fn -help []{
|
|||
echo 'Si aucune classe de caractères ou liste de caractères n’est fournie, utilise les caractères alphanumériques ([A-Za-z0-9]).'
|
||||
}
|
||||
|
||||
edit:add-var genstr~ [@args]{
|
||||
edit:add-var genstr~ {|@args|
|
||||
var len chars h = 0 '' $false
|
||||
each [e]{
|
||||
each {|e|
|
||||
if (or (eq $e -h) (eq $e --help)) {
|
||||
set h = $true
|
||||
-help
|
||||
|
|
@ -86,7 +86,7 @@ edit:add-var genstr~ [@args]{
|
|||
|
||||
set chars = [(str:split '' $chars)]
|
||||
|
||||
range $len | each [_]{
|
||||
range $len | each {|_|
|
||||
-random $chars
|
||||
}
|
||||
echo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue