0.0.4
This commit is contained in:
parent
675e067f03
commit
67ef883539
14 changed files with 3704 additions and 5 deletions
3
index.js
3
index.js
|
@ -1,7 +1,6 @@
|
||||||
const { writeFile, readFile, mkdir } = require('node:fs/promises');
|
const { writeFile, readFile, mkdir } = require('node:fs/promises');
|
||||||
const readline = require ('node:readline/promises');
|
|
||||||
const { stdin, stdout } = require('node:process');
|
const { stdin, stdout } = require('node:process');
|
||||||
var readlineSync = require('readline-sync');
|
var readlineSync = require('@fiusdevelopment/readline');
|
||||||
var name;
|
var name;
|
||||||
|
|
||||||
function getTime () {
|
function getTime () {
|
||||||
|
|
13
node_modules/.package-lock.json
generated
vendored
Normal file
13
node_modules/.package-lock.json
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "@fiusdevelopment/std",
|
||||||
|
"version": "0.0.3",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@fiusdevelopment/readline": {
|
||||||
|
"version": "0.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fiusdevelopment/readline/-/readline-0.0.2.tgz",
|
||||||
|
"integrity": "sha512-BYGUnOZQ2bTv4D3BDdsqM74Mck8iDwBAS18Oo/gB+8PX241xi4GYGE4JoKF6+MLQuFJ92+ohaUY0PBPmIxn0kQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
node_modules/@fiusdevelopment/readline/.github/workflows/main.yml
generated
vendored
Normal file
44
node_modules/@fiusdevelopment/readline/.github/workflows/main.yml
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
name: Publish to NPM
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
jobs:
|
||||||
|
Publish-NPM:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16.x'
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
scope: '@fiusdevelopment'
|
||||||
|
- name: Install dependencies 🔧
|
||||||
|
run: npm ci
|
||||||
|
- name: Publish package on NPM 📦
|
||||||
|
run: npm publish --access public
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
REGISTRY1: 'registry.npmjs.org'
|
||||||
|
REGISTRY2: 'registry=https://registry.npmjs.org/'
|
||||||
|
|
||||||
|
Publish-GitHub-NPM:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '16.x'
|
||||||
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
|
scope: '@fiusdevelopment'
|
||||||
|
- name: Install dependencies 🔧
|
||||||
|
run: npm ci
|
||||||
|
- name: Publish package on NPM 📦
|
||||||
|
run: npm publish --access public
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.GP_TOKEN }}
|
||||||
|
REGISTRY1: 'npm.pkg.github.com'
|
||||||
|
REGISTRY2: '@fiusdevelopment:registry=https://npm.pkg.github.com'
|
61
node_modules/@fiusdevelopment/readline/LICENSE
generated
vendored
Normal file
61
node_modules/@fiusdevelopment/readline/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
FIUS License V1.1
|
||||||
|
----------------------------------------------------------------
|
||||||
|
1. Definitions
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.3. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Code that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.4. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.5. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
1.6. "The owners"
|
||||||
|
Who own this project
|
||||||
|
|
||||||
|
1.7. "The code" / "The Software" / "The project" / "The idea"
|
||||||
|
It means the product or creation that this document governs (Including the idea).
|
||||||
|
|
||||||
|
------------------------------------------------
|
||||||
|
2. License Grants, Conditions and Limitation
|
||||||
|
|
||||||
|
2.1. Each contributor has ownership of what he creates, no exceptions.
|
||||||
|
It may require the removal of what it creates from the project,
|
||||||
|
the removal may be denied.
|
||||||
|
|
||||||
|
2.2. You can Contribute at the project by request.
|
||||||
|
|
||||||
|
2.3. You can't copy or share the code.
|
||||||
|
|
||||||
|
2.4. You can't get / use this code from here, you have to get a public
|
||||||
|
from a public source.
|
||||||
|
|
||||||
|
2.5. The owners have the full rights and choice what to do of this project,
|
||||||
|
including your contribution.
|
1834
node_modules/@fiusdevelopment/readline/README.md
generated
vendored
Normal file
1834
node_modules/@fiusdevelopment/readline/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
16
node_modules/@fiusdevelopment/readline/lib/encrypt.js
generated
vendored
Normal file
16
node_modules/@fiusdevelopment/readline/lib/encrypt.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
var cipher = require('crypto').createCipher(
|
||||||
|
process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
|
||||||
|
stdin = process.stdin,
|
||||||
|
stdout = process.stdout,
|
||||||
|
crypted = '';
|
||||||
|
|
||||||
|
stdin.resume();
|
||||||
|
stdin.setEncoding('utf8');
|
||||||
|
stdin.on('data', function(d) {
|
||||||
|
crypted += cipher.update(d, 'utf8', 'hex');
|
||||||
|
});
|
||||||
|
stdin.on('end', function() {
|
||||||
|
stdout.write(crypted + cipher.final('hex'), 'binary', function() {
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
});
|
122
node_modules/@fiusdevelopment/readline/lib/read.ps1
generated
vendored
Normal file
122
node_modules/@fiusdevelopment/readline/lib/read.ps1
generated
vendored
Normal file
|
@ -0,0 +1,122 @@
|
||||||
|
Param(
|
||||||
|
[string] $display,
|
||||||
|
[switch] $displayOnly,
|
||||||
|
[switch] $keyIn,
|
||||||
|
[switch] $hideEchoBack,
|
||||||
|
[string] $mask,
|
||||||
|
[string] $limit,
|
||||||
|
[switch] $caseSensitive
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'Stop' # for cmdlet
|
||||||
|
trap {
|
||||||
|
# `throw $_` and `Write-Error $_` return exit-code 0
|
||||||
|
$Host.UI.WriteErrorLine($_)
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function decodeArg ($arg) {
|
||||||
|
[Regex]::Replace($arg, '#(\d+);', { [char][int] $args[0].Groups[1].Value })
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = @{}
|
||||||
|
foreach ($arg in @('display', 'displayOnly', 'keyIn', 'hideEchoBack', 'mask', 'limit', 'caseSensitive')) {
|
||||||
|
$options.Add($arg, (Get-Variable $arg -ValueOnly))
|
||||||
|
}
|
||||||
|
$argList = New-Object string[] $options.Keys.Count
|
||||||
|
$options.Keys.CopyTo($argList, 0)
|
||||||
|
foreach ($arg in $argList) {
|
||||||
|
if ($options[$arg] -is [string] -and $options[$arg])
|
||||||
|
{ $options[$arg] = decodeArg $options[$arg] }
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] $inputTTY = ''
|
||||||
|
[bool] $silent = -not $options.display -and
|
||||||
|
$options.keyIn -and $options.hideEchoBack -and -not $options.mask
|
||||||
|
[bool] $isCooked = -not $options.hideEchoBack -and -not $options.keyIn
|
||||||
|
|
||||||
|
# Instant method that opens TTY without CreateFile via P/Invoke in .NET Framework
|
||||||
|
# **NOTE** Don't include special characters of DOS in $command when $getRes is True.
|
||||||
|
# [string] $cmdPath = $Env:ComSpec
|
||||||
|
# [string] $psPath = 'powershell.exe'
|
||||||
|
function execWithTTY ($command, $getRes = $False, $throwError = $False) {
|
||||||
|
if ($getRes) {
|
||||||
|
$res = (cmd.exe /C "<CON powershell.exe -Command $command")
|
||||||
|
if ($LastExitCode -ne 0) {
|
||||||
|
if ($throwError) { throw $LastExitCode }
|
||||||
|
else { exit $LastExitCode }
|
||||||
|
}
|
||||||
|
return $res
|
||||||
|
} else {
|
||||||
|
$command | cmd.exe /C ">CON powershell.exe -Command -"
|
||||||
|
if ($LastExitCode -ne 0) {
|
||||||
|
if ($throwError) { throw $LastExitCode }
|
||||||
|
else { exit $LastExitCode }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeTTY ($text) {
|
||||||
|
execWithTTY ('Write-Host (''' +
|
||||||
|
(($text -replace '''', '''''') -replace '[\r\n]', '''+"`n"+''') + ''') -NoNewline')
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($options.display) {
|
||||||
|
writeTTY $options.display
|
||||||
|
}
|
||||||
|
if ($options.displayOnly) { return "''" }
|
||||||
|
|
||||||
|
if (-not $options.keyIn -and $options.hideEchoBack -and $options.mask -eq '*') {
|
||||||
|
# It fails when it's not ready.
|
||||||
|
try {
|
||||||
|
$inputTTY = execWithTTY ('$text = Read-Host -AsSecureString;' +
|
||||||
|
'$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($text);' +
|
||||||
|
'[Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)') $True $True
|
||||||
|
return '''' + $inputTTY + ''''
|
||||||
|
} catch {} # ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($options.keyIn) { $reqSize = 1 }
|
||||||
|
|
||||||
|
if ($options.keyIn -and $options.limit) {
|
||||||
|
$limitPtn = '[^' + $options.limit + ']'
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($True) {
|
||||||
|
if (-not $isCooked) {
|
||||||
|
$chunk = [char][int] (execWithTTY '[int] [Console]::ReadKey($True).KeyChar' $True)
|
||||||
|
} else {
|
||||||
|
$chunk = execWithTTY 'Read-Host' $True
|
||||||
|
$chunk += "`n"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($chunk -and $chunk -match '^(.*?)[\r\n]') {
|
||||||
|
$chunk = $Matches[1]
|
||||||
|
$atEol = $True
|
||||||
|
} else { $atEol = $False }
|
||||||
|
|
||||||
|
# other ctrl-chars
|
||||||
|
if ($chunk) { $chunk = $chunk -replace '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]', '' }
|
||||||
|
if ($chunk -and $limitPtn) {
|
||||||
|
if ($options.caseSensitive) { $chunk = $chunk -creplace $limitPtn, '' }
|
||||||
|
else { $chunk = $chunk -ireplace $limitPtn, '' }
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($chunk) {
|
||||||
|
if (-not $isCooked) {
|
||||||
|
if (-not $options.hideEchoBack) {
|
||||||
|
writeTTY $chunk
|
||||||
|
} elseif ($options.mask) {
|
||||||
|
writeTTY ($options.mask * $chunk.Length)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$inputTTY += $chunk
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((-not $options.keyIn -and $atEol) -or
|
||||||
|
($options.keyIn -and $inputTTY.Length -ge $reqSize)) { break }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $isCooked -and -not $silent) { execWithTTY 'Write-Host ''''' } # new line
|
||||||
|
|
||||||
|
return "'$inputTTY'"
|
128
node_modules/@fiusdevelopment/readline/lib/read.sh
generated
vendored
Normal file
128
node_modules/@fiusdevelopment/readline/lib/read.sh
generated
vendored
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
decode_arg() {
|
||||||
|
printf '%s' "$(printf '%s' "$1" | perl -pe 's/#(\d+);/sprintf("%c", $1)/ge; s/[\r\n]/\fNL/g')"
|
||||||
|
}
|
||||||
|
|
||||||
|
# getopt(s)
|
||||||
|
while [ $# -ge 1 ]; do
|
||||||
|
arg="$(printf '%s' "$1" | grep -E '^-+[^-]+$' | tr '[A-Z]' '[a-z]' | tr -d '-')"
|
||||||
|
case "$arg" in
|
||||||
|
'display') shift; options_display="$(decode_arg "$1")";;
|
||||||
|
'displayonly') options_displayOnly=true;;
|
||||||
|
'keyin') options_keyIn=true;;
|
||||||
|
'hideechoback') options_hideEchoBack=true;;
|
||||||
|
'mask') shift; options_mask="$(decode_arg "$1")";;
|
||||||
|
'limit') shift; options_limit="$(decode_arg "$1")";;
|
||||||
|
'casesensitive') options_caseSensitive=true;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
reset_tty() {
|
||||||
|
if [ -n "$save_tty" ]; then
|
||||||
|
stty --file=/dev/tty "$save_tty" 2>/dev/null || \
|
||||||
|
stty -F /dev/tty "$save_tty" 2>/dev/null || \
|
||||||
|
stty -f /dev/tty "$save_tty" || exit $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap 'reset_tty' EXIT
|
||||||
|
save_tty="$(stty --file=/dev/tty -g 2>/dev/null || stty -F /dev/tty -g 2>/dev/null || stty -f /dev/tty -g || exit $?)"
|
||||||
|
|
||||||
|
[ -z "$options_display" ] && [ "$options_keyIn" = true ] && \
|
||||||
|
[ "$options_hideEchoBack" = true ] && [ -z "$options_mask" ] && silent=true
|
||||||
|
[ "$options_hideEchoBack" != true ] && [ "$options_keyIn" != true ] && is_cooked=true
|
||||||
|
|
||||||
|
write_tty() {
|
||||||
|
# if [ "$2" = true ]; then
|
||||||
|
# printf '%b' "$1" >/dev/tty
|
||||||
|
# else
|
||||||
|
# printf '%s' "$1" >/dev/tty
|
||||||
|
# fi
|
||||||
|
printf '%s' "$1" | perl -pe 's/\fNL/\r\n/g' >/dev/tty
|
||||||
|
}
|
||||||
|
|
||||||
|
replace_allchars() { (
|
||||||
|
text=''
|
||||||
|
for i in $(seq 1 ${#1})
|
||||||
|
do
|
||||||
|
text="$text$2"
|
||||||
|
done
|
||||||
|
printf '%s' "$text"
|
||||||
|
) }
|
||||||
|
|
||||||
|
if [ -n "$options_display" ]; then
|
||||||
|
write_tty "$options_display"
|
||||||
|
fi
|
||||||
|
if [ "$options_displayOnly" = true ]; then
|
||||||
|
printf "'%s'" ''
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$is_cooked" = true ]; then
|
||||||
|
stty --file=/dev/tty cooked 2>/dev/null || \
|
||||||
|
stty -F /dev/tty cooked 2>/dev/null || \
|
||||||
|
stty -f /dev/tty cooked || exit $?
|
||||||
|
else
|
||||||
|
stty --file=/dev/tty raw -echo 2>/dev/null || \
|
||||||
|
stty -F /dev/tty raw -echo 2>/dev/null || \
|
||||||
|
stty -f /dev/tty raw -echo || exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$options_keyIn" = true ] && req_size=1
|
||||||
|
|
||||||
|
if [ "$options_keyIn" = true ] && [ -n "$options_limit" ]; then
|
||||||
|
if [ "$options_caseSensitive" = true ]; then
|
||||||
|
limit_ptn="$options_limit"
|
||||||
|
else
|
||||||
|
# Safe list
|
||||||
|
# limit_ptn="$(printf '%s' "$options_limit" | sed 's/\([a-z]\)/\L\1\U\1/ig')"
|
||||||
|
limit_ptn="$(printf '%s' "$options_limit" | perl -pe 's/([a-z])/lc($1) . uc($1)/ige')"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
if [ "$is_cooked" != true ]; then
|
||||||
|
# chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null)"
|
||||||
|
chunk="$(dd if=/dev/tty bs=1 count=1 2>/dev/null | perl -pe 's/[\r\n]/\fNL/g')"
|
||||||
|
else
|
||||||
|
IFS= read -r chunk </dev/tty || exit $?
|
||||||
|
chunk="$(printf '%s\fNL' "$chunk")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if [ -n "$chunk" ] && [ "$(printf '%s' "$chunk" | tr '\r' '\n' | wc -l)" != "0" ]; then
|
||||||
|
# chunk="$(printf '%s' "$chunk" | tr '\r' '\n' | head -n 1)"
|
||||||
|
if [ -n "$chunk" ] && printf '%s' "$chunk" | perl -ne '/\fNL/ or exit 1'; then
|
||||||
|
chunk="$(printf '%s' "$chunk" | perl -pe 's/^(.*?)\fNL.*$/$1/')"
|
||||||
|
at_eol=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# other ctrl-chars
|
||||||
|
if [ -n "$chunk" ]; then
|
||||||
|
# chunk="$(printf '%s' "$chunk" | tr -d '\00-\10\13\14\16-\37\177')"
|
||||||
|
# for System V
|
||||||
|
chunk="$(printf '%s' "$chunk" | tr -d '\00\01\02\03\04\05\06\07\10\13\14\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177')"
|
||||||
|
fi
|
||||||
|
if [ -n "$chunk" ] && [ -n "$limit_ptn" ]; then
|
||||||
|
chunk="$(printf '%s' "$chunk" | tr -cd "$limit_ptn")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$chunk" ]; then
|
||||||
|
if [ "$is_cooked" != true ]; then
|
||||||
|
if [ "$options_hideEchoBack" != true ]; then
|
||||||
|
write_tty "$chunk"
|
||||||
|
elif [ -n "$options_mask" ]; then
|
||||||
|
write_tty "$(replace_allchars "$chunk" "$options_mask")"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
input="$input$chunk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ( [ "$options_keyIn" != true ] && [ "$at_eol" = true ] ) || \
|
||||||
|
( [ "$options_keyIn" = true ] && [ ${#input} -ge $req_size ] ); then break; fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$is_cooked" != true ] && [ "$silent" != true ]; then write_tty "$(printf '%b' '\fNL')"; fi
|
||||||
|
|
||||||
|
printf "'%s'" "$input"
|
||||||
|
|
||||||
|
exit 0
|
113
node_modules/@fiusdevelopment/readline/lib/read.wsh.js
generated
vendored
Normal file
113
node_modules/@fiusdevelopment/readline/lib/read.wsh.js
generated
vendored
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
var
|
||||||
|
FSO_ForReading = 1, FSO_ForWriting = 2,
|
||||||
|
PS_MSG = 'Microsoft Windows PowerShell is required.' +
|
||||||
|
' https://technet.microsoft.com/en-us/library/hh847837.aspx',
|
||||||
|
|
||||||
|
input = '', fso, tty,
|
||||||
|
options = (function(conf) {
|
||||||
|
var options = {}, arg, args =// Array.prototype.slice.call(WScript.Arguments),
|
||||||
|
(function() {
|
||||||
|
var args = [], i, iLen;
|
||||||
|
for (i = 0, iLen = WScript.Arguments.length; i < iLen; i++)
|
||||||
|
{ args.push(WScript.Arguments(i)); }
|
||||||
|
return args;
|
||||||
|
})(),
|
||||||
|
confLc = {}, key;
|
||||||
|
|
||||||
|
function decodeArg(arg) {
|
||||||
|
return arg.replace(/#(\d+);/g, function(str, charCode) {
|
||||||
|
return String.fromCharCode(+charCode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (key in conf) {
|
||||||
|
if (conf.hasOwnProperty(key))
|
||||||
|
{ confLc[key.toLowerCase()] = {key: key, type: conf[key]}; }
|
||||||
|
}
|
||||||
|
|
||||||
|
while (typeof(arg = args.shift()) === 'string') {
|
||||||
|
if (!(arg = (arg.match(/^\-+(.+)$/) || [])[1])) { continue; }
|
||||||
|
arg = arg.toLowerCase();
|
||||||
|
if (confLc[arg]) {
|
||||||
|
options[confLc[arg].key] =
|
||||||
|
confLc[arg].type === 'boolean' ? true :
|
||||||
|
confLc[arg].type === 'string' ? args.shift() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (key in conf) {
|
||||||
|
if (conf.hasOwnProperty(key) && conf[key] === 'string') {
|
||||||
|
if (typeof options[key] !== 'string') { options[key] = ''; }
|
||||||
|
else { options[key] = decodeArg(options[key]); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
})({
|
||||||
|
display: 'string',
|
||||||
|
displayOnly: 'boolean',
|
||||||
|
keyIn: 'boolean',
|
||||||
|
hideEchoBack: 'boolean',
|
||||||
|
mask: 'string'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!options.hideEchoBack && !options.keyIn) {
|
||||||
|
if (options.display) { writeTTY(options.display); }
|
||||||
|
if (!options.displayOnly) { input = readByFSO(); }
|
||||||
|
} else if (options.hideEchoBack && !options.keyIn && !options.mask) {
|
||||||
|
if (options.display) { writeTTY(options.display); }
|
||||||
|
if (!options.displayOnly) { input = readByPW(); }
|
||||||
|
} else {
|
||||||
|
WScript.StdErr.WriteLine(PS_MSG);
|
||||||
|
WScript.Quit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
WScript.StdOut.Write('\'' + input + '\'');
|
||||||
|
|
||||||
|
WScript.Quit();
|
||||||
|
|
||||||
|
function writeTTY(text) {
|
||||||
|
try {
|
||||||
|
tty = tty || getFso().OpenTextFile('CONOUT$', FSO_ForWriting, true);
|
||||||
|
tty.Write(text);
|
||||||
|
} catch (e) {
|
||||||
|
WScript.StdErr.WriteLine('TTY Write Error: ' + e.number +
|
||||||
|
'\n' + e.description + '\n' + PS_MSG);
|
||||||
|
WScript.Quit(e.number || 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function readByFSO() {
|
||||||
|
var text;
|
||||||
|
try {
|
||||||
|
text = getFso().OpenTextFile('CONIN$', FSO_ForReading).ReadLine();
|
||||||
|
} catch (e) {
|
||||||
|
WScript.StdErr.WriteLine('TTY Read Error: ' + e.number +
|
||||||
|
'\n' + e.description + '\n' + PS_MSG);
|
||||||
|
WScript.Quit(e.number || 1);
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TTY must be STDIN that is not redirected and not piped.
|
||||||
|
function readByPW() {
|
||||||
|
var text;
|
||||||
|
try {
|
||||||
|
text = WScript.CreateObject('ScriptPW.Password').GetPassword()
|
||||||
|
// Bug? Illegal data may be returned when user types before initializing.
|
||||||
|
.replace(/[\u4000-\u40FF]/g, function(chr) {
|
||||||
|
var charCode = chr.charCodeAt(0);
|
||||||
|
return charCode >= 0x4020 && charCode <= 0x407F ?
|
||||||
|
String.fromCharCode(charCode - 0x4000) : '';
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
WScript.StdErr.WriteLine('ScriptPW.Password Error: ' + e.number +
|
||||||
|
'\n' + e.description + '\n' + PS_MSG);
|
||||||
|
WScript.Quit(e.number || 1);
|
||||||
|
}
|
||||||
|
writeTTY('\n');
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFso() {
|
||||||
|
if (!fso) { fso = new ActiveXObject('Scripting.FileSystemObject'); }
|
||||||
|
return fso;
|
||||||
|
}
|
1321
node_modules/@fiusdevelopment/readline/lib/readline-sync.js
generated
vendored
Normal file
1321
node_modules/@fiusdevelopment/readline/lib/readline-sync.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
30
node_modules/@fiusdevelopment/readline/package.json
generated
vendored
Normal file
30
node_modules/@fiusdevelopment/readline/package.json
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "@fiusdevelopment/readline",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"title": "readlineSync",
|
||||||
|
"description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).",
|
||||||
|
"keywords": [
|
||||||
|
"readline",
|
||||||
|
"synchronous",
|
||||||
|
"interactive",
|
||||||
|
"prompt",
|
||||||
|
"question",
|
||||||
|
"password",
|
||||||
|
"cli",
|
||||||
|
"tty",
|
||||||
|
"command",
|
||||||
|
"repl",
|
||||||
|
"keyboard",
|
||||||
|
"wait",
|
||||||
|
"block"
|
||||||
|
],
|
||||||
|
"main": "./lib/readline-sync.js",
|
||||||
|
"homepage": "https://github.com/anseki/readline-sync",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/FIUSDevelopment/readline-sync.git"
|
||||||
|
},
|
||||||
|
"bugs": "https://github.com/FIUSDevelopment/readline-sync/issues",
|
||||||
|
"license": "MIT",
|
||||||
|
"author": "FIUS Development | Killer Boss Original"
|
||||||
|
}
|
BIN
node_modules/@fiusdevelopment/readline/screen_1.gif
generated
vendored
Normal file
BIN
node_modules/@fiusdevelopment/readline/screen_1.gif
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -7,7 +7,22 @@
|
||||||
"": {
|
"": {
|
||||||
"name": "@fiusdevelopment/std",
|
"name": "@fiusdevelopment/std",
|
||||||
"version": "0.0.3",
|
"version": "0.0.3",
|
||||||
"license": "SEE LICENSE IN LICENSE.txt"
|
"license": "SEE LICENSE IN LICENSE.txt",
|
||||||
|
"dependencies": {
|
||||||
|
"@fiusdevelopment/readline": "^0.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fiusdevelopment/readline": {
|
||||||
|
"version": "0.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fiusdevelopment/readline/-/readline-0.0.2.tgz",
|
||||||
|
"integrity": "sha512-BYGUnOZQ2bTv4D3BDdsqM74Mck8iDwBAS18Oo/gB+8PX241xi4GYGE4JoKF6+MLQuFJ92+ohaUY0PBPmIxn0kQ=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fiusdevelopment/readline": {
|
||||||
|
"version": "0.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fiusdevelopment/readline/-/readline-0.0.2.tgz",
|
||||||
|
"integrity": "sha512-BYGUnOZQ2bTv4D3BDdsqM74Mck8iDwBAS18Oo/gB+8PX241xi4GYGE4JoKF6+MLQuFJ92+ohaUY0PBPmIxn0kQ=="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@fiusdevelopment/std",
|
"name": "@fiusdevelopment/std",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"description": "Standard module for javascript",
|
"description": "Standard module for javascript",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -23,5 +23,8 @@
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/FIUSDevelopment/std/issues"
|
"url": "https://github.com/FIUSDevelopment/std/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/FIUSDevelopment/std#readme"
|
"homepage": "https://github.com/FIUSDevelopment/std#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@fiusdevelopment/readline": "^0.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue