using unix convention for cmd args

This commit is contained in:
minjaesong
2023-05-10 09:41:43 +09:00
parent beecc0b5eb
commit ba5c87530f
16 changed files with 34 additions and 34 deletions

View File

@@ -5,4 +5,4 @@ set PATH=\tvdos\installer;\tvdos\tuidev;$PATH
set KEYBOARD=us_colemak set KEYBOARD=us_colemak
rem this line specifies which shell to be presented after the boot precess: rem this line specifies which shell to be presented after the boot precess:
command /fancy command -fancy

View File

@@ -460,21 +460,21 @@ _G.shell = shell;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (exec_args[1] !== undefined) { if (exec_args[1] !== undefined) {
// only meaningful switches would be either /c or /k anyway // only meaningful switches would be either -c or -k anyway
var firstSwitch = exec_args[1].toLowerCase(); var firstSwitch = exec_args[1].toLowerCase();
// command /c <commands> // command -c <commands>
// ^[0] ^[1] ^[2] // ^[0] ^[1] ^[2]
if ("/c" == firstSwitch) { if ("-c" == firstSwitch) {
if ("" == exec_args[2]) return 0; // no commands were given, just exit successfully if ("" == exec_args[2]) return 0; // no commands were given, just exit successfully
return shell.execute(exec_args[2]); return shell.execute(exec_args[2]);
} }
else if ("/k" == firstSwitch) { else if ("-k" == firstSwitch) {
if ("" == exec_args[2]) return 0; // no commands were given, just exit successfully if ("" == exec_args[2]) return 0; // no commands were given, just exit successfully
shell.execute(exec_args[2]); shell.execute(exec_args[2]);
goInteractive = true; goInteractive = true;
} }
else if ("/fancy" == firstSwitch) { else if ("-fancy" == firstSwitch) {
graphics.setBackground(2,3,4); graphics.setBackground(2,3,4);
goFancy = true; goFancy = true;
goInteractive = true; goInteractive = true;

View File

@@ -5,4 +5,4 @@ rem e.g. set PATH=\home\my-cool-project;$PATH
set KEYBOARD=us_qwerty set KEYBOARD=us_qwerty
rem this line specifies which shell to be presented after the boot precess: rem this line specifies which shell to be presented after the boot precess:
command /fancy command -fancy

View File

@@ -1236,4 +1236,4 @@ serial.println(`TVDOS.SYS initialised on VM ${sys.getVmId()}, running boot scrip
var _G = {}; var _G = {};
let cmdfile = files.open("A:/tvdos/bin/command.js") let cmdfile = files.open("A:/tvdos/bin/command.js")
eval(`var _AUTOEXEC=function(exec_args){${cmdfile.sread()}\n};` + eval(`var _AUTOEXEC=function(exec_args){${cmdfile.sread()}\n};` +
`_AUTOEXEC`)(["", "/c", "\\AUTOEXEC.BAT"]) `_AUTOEXEC`)(["", "-c", "\\AUTOEXEC.BAT"])

View File

@@ -848,21 +848,21 @@ _G.shell = shell
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (exec_args[1] !== undefined) { if (exec_args[1] !== undefined) {
// only meaningful switches would be either /c or /k anyway // only meaningful switches would be either -c or -k anyway
var firstSwitch = exec_args[1].toLowerCase() var firstSwitch = exec_args[1].toLowerCase()
// command /c <commands> // command -c <commands>
// ^[0] ^[1] ^[2] // ^[0] ^[1] ^[2]
if ("/c" == firstSwitch) { if ("-c" == firstSwitch) {
if ("" == exec_args[2]) return 0 // no commands were given, just exit successfully if ("" == exec_args[2]) return 0 // no commands were given, just exit successfully
return shell.execute(exec_args[2]) return shell.execute(exec_args[2])
} }
else if ("/k" == firstSwitch) { else if ("-k" == firstSwitch) {
if ("" == exec_args[2]) return 0 // no commands were given, just exit successfully if ("" == exec_args[2]) return 0 // no commands were given, just exit successfully
shell.execute(exec_args[2]) shell.execute(exec_args[2])
goInteractive = true goInteractive = true
} }
else if ("/fancy" == firstSwitch) { else if ("-fancy" == firstSwitch) {
graphics.setBackground(34,51,68) graphics.setBackground(34,51,68)
goFancy = true goFancy = true
goInteractive = true goInteractive = true

View File

@@ -3,7 +3,7 @@ if (exec_args[1] == undefined) {
return 1 return 1
} }
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
let infile = files.open(_G.shell.resolvePathInput(exec_args[1]).full) let infile = files.open(_G.shell.resolvePathInput(exec_args[1]).full)
// read input file // read input file

View File

@@ -1,9 +1,9 @@
if (exec_args[3] == undefined) { if (exec_args[3] == undefined) {
println("encodeipf <1/2> <input picture> <output filename> [/noalpha]") println("encodeipf <1/2> <input picture> <output filename> [-noalpha]")
return 1 return 1
} }
let noalpha = exec_args[4] != undefined && exec_args[4].toLowerCase() == "/noalpha" let noalpha = exec_args[4] != undefined && exec_args[4].toLowerCase() == "-noalpha"
let infile = files.open(_G.shell.resolvePathInput(exec_args[2]).full) let infile = files.open(_G.shell.resolvePathInput(exec_args[2]).full)
let outfile = files.open(_G.shell.resolvePathInput(exec_args[3]).full) let outfile = files.open(_G.shell.resolvePathInput(exec_args[3]).full)

View File

@@ -1,13 +1,13 @@
function printUsage() { function printUsage() {
println(`Usage: gzip [/d /c] file println(`Usage: gzip [-c] [-d] file
To compress a file, replacing it with a gzipped compressed version: To compress a file, replacing it with a gzipped compressed version:
gzip file.ext gzip file.ext
To decompress a file, replacing it with the original uncompressed version: To decompress a file, replacing it with the original uncompressed version:
gzip /d file.ext.gz gzip -d file.ext.gz
To compress a file specifying the output filename: To compress a file specifying the output filename:
gzip /c file.ext > compressed_file.ext.gz gzip -c file.ext > compressed_file.ext.gz
To decompress a gzipped file specifying the output filename: To decompress a gzipped file specifying the output filename:
gzip /c /d file.ext.gz > uncompressed_file.ext`) gzip -c -d file.ext.gz > uncompressed_file.ext`)
} }
if (exec_args[1] === undefined) { if (exec_args[1] === undefined) {
@@ -23,8 +23,8 @@ if (filePath === undefined) {
return 0 return 0
} }
const decompMode = (options.indexOf("/D") >= 0) const decompMode = (options.indexOf("-D") >= 0)
const toStdout = (options.indexOf("/C") >= 0) const toStdout = (options.indexOf("-C") >= 0)
const file = files.open(_G.shell.resolvePath(filePath).full) const file = files.open(_G.shell.resolvePath(filePath).full)

View File

@@ -1,6 +1,6 @@
// usage: playmov moviefile.mov [/i] // usage: playmov moviefile.mov [/i]
const SND_BASE_ADDR = audio.getBaseAddr() const SND_BASE_ADDR = audio.getBaseAddr()
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
const WIDTH = 560 const WIDTH = 560
const HEIGHT = 448 const HEIGHT = 448
const FBUF_SIZE = WIDTH * HEIGHT const FBUF_SIZE = WIDTH * HEIGHT

View File

@@ -5,7 +5,7 @@ if (!SND_BASE_ADDR) return 10
const MP2_BITRATES = ["???", 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384] const MP2_BITRATES = ["???", 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384]
const MP2_CHANNELMODES = ["Stereo", "Joint", "Dual", "Mono"] const MP2_CHANNELMODES = ["Stereo", "Joint", "Dual", "Mono"]
const pcm = require("pcm") const pcm = require("pcm")
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
function printdbg(s) { if (0) serial.println(s) } function printdbg(s) { if (0) serial.println(s) }

View File

@@ -5,7 +5,7 @@ return 1
const Mp3 = require('mp3dec') const Mp3 = require('mp3dec')
const pcm = require("pcm") const pcm = require("pcm")
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
function printdbg(s) { if (0) serial.println(s) } function printdbg(s) { if (0) serial.println(s) }

View File

@@ -3,7 +3,7 @@ let fileeeee = files.open(_G.shell.resolvePathInput(exec_args[1]).full)
let filename = fileeeee.fullPath let filename = fileeeee.fullPath
function printdbg(s) { if (0) serial.println(s) } function printdbg(s) { if (0) serial.println(s) }
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
const pcm = require("pcm") const pcm = require("pcm")
const FILE_SIZE = files.open(filename).size const FILE_SIZE = files.open(filename).size

View File

@@ -5,7 +5,7 @@ function printdbg(s) { if (0) serial.println(s) }
const WAV_FORMATS = ["LPCM", "ADPCM"] const WAV_FORMATS = ["LPCM", "ADPCM"]
const WAV_CHANNELS = ["Mono", "Stereo", "3ch", "Quad", "4.1", "5.1", "6.1", "7.1"] const WAV_CHANNELS = ["Mono", "Stereo", "3ch", "Quad", "4.1", "5.1", "6.1", "7.1"]
const interactive = exec_args[2] && exec_args[2].toLowerCase() == "/i" const interactive = exec_args[2] && exec_args[2].toLowerCase() == "-i"
const seqread = require("seqread") const seqread = require("seqread")
const pcm = require("pcm") const pcm = require("pcm")

View File

@@ -8,7 +8,7 @@ if (exec_args[1] === undefined) {
return 1; return 1;
} }
let noNewFile = (exec_args[1] == "/c" || exec_args[1] == "/C"); let noNewFile = (exec_args[1] == "-c" || exec_args[1] == "-C");
let file = files.open(`${_G.shell.resolvePathInput(exec_args[2] || exec_args[1]).full}`) let file = files.open(`${_G.shell.resolvePathInput(exec_args[2] || exec_args[1]).full}`)
if (!file.exists && noNewFile) { if (!file.exists && noNewFile) {
printerrln("TOUCH: Can't open "+file.fullPath+" due to IO error"); printerrln("TOUCH: Can't open "+file.fullPath+" due to IO error");

View File

@@ -5,4 +5,4 @@ rem e.g. set PATH=\home\my-cool-project;$PATH
set KEYBOARD=us_qwerty set KEYBOARD=us_qwerty
rem this line specifies which shell to be presented after the boot precess: rem this line specifies which shell to be presented after the boot precess:
command /fancy command -fancy

View File

@@ -76,7 +76,7 @@ This chapter will only briefly list and describe the applications.
\1\dossynopsis{basica}{Invokes a BASIC interpreter stored in the ROM. If no BASIC rom is present, nothing will be done.} \1\dossynopsis{basica}{Invokes a BASIC interpreter stored in the ROM. If no BASIC rom is present, nothing will be done.}
\1\dossynopsis{basic}{If your system is bundled with a software-based BASIC, this command will invoke the BASIC interpreter stored in the disk.} \1\dossynopsis{basic}{If your system is bundled with a software-based BASIC, this command will invoke the BASIC interpreter stored in the disk.}
\1\dossynopsis{color}{Changes the background and the foreground of the active session.} \1\dossynopsis{color}{Changes the background and the foreground of the active session.}
\1\dossynopsis{command}{The default text-based DOS shell. Call with \code{command /fancy} for more \ae sthetically pleasing looks.} \1\dossynopsis{command}{The default text-based DOS shell. Call with \code{command -fancy} for more \ae sthetically pleasing looks.}
\1\dossynopsis{decodeipf}[file]{Decodes the IPF-formatted image to the framebuffer using the graphics processor.} \1\dossynopsis{decodeipf}[file]{Decodes the IPF-formatted image to the framebuffer using the graphics processor.}
\1\dossynopsis{drives}{Shows the list of the connected and mounted disk drives.} \1\dossynopsis{drives}{Shows the list of the connected and mounted disk drives.}
\1\dossynopsis{edit}[file]{The interactive full-screen text editor.} \1\dossynopsis{edit}[file]{The interactive full-screen text editor.}
@@ -85,10 +85,10 @@ This chapter will only briefly list and describe the applications.
\1\dossynopsis{geturl}[url]{Reads contents on the web address and store it to the disk. Requires Internet adapter.} \1\dossynopsis{geturl}[url]{Reads contents on the web address and store it to the disk. Requires Internet adapter.}
\1\dossynopsis{hexdump}[file]{Prints out the contents of a file in hexadecimal view. Supports pipe.} \1\dossynopsis{hexdump}[file]{Prints out the contents of a file in hexadecimal view. Supports pipe.}
\1\dossynopsis{less}[file]{Allows user to read the long text, even if they are wider and/or taller than the screen. Supports pipe.} \1\dossynopsis{less}[file]{Allows user to read the long text, even if they are wider and/or taller than the screen. Supports pipe.}
\1\dossynopsis{playmov}[file]{Plays tsvmmov-formatted video. Use /i flag for playback control.} \1\dossynopsis{playmov}[file]{Plays tsvmmov-formatted video. Use -i flag for playback control.}
\1\dossynopsis{playmp2}[file]{Plays MP2 (MPEG-1 Audio Layer II) formatted audio. Use /i flag for playback control.} \1\dossynopsis{playmp2}[file]{Plays MP2 (MPEG-1 Audio Layer II) formatted audio. Use -i flag for playback control.}
\1\dossynopsis{playpcm}[file]{Plays raw PCM audio. Use /i flag for playback control.} \1\dossynopsis{playpcm}[file]{Plays raw PCM audio. Use -i flag for playback control.}
\1\dossynopsis{playwav}[file]{Plays linear PCM/ADPCM audio. Use /i flag for playback control.} \1\dossynopsis{playwav}[file]{Plays linear PCM/ADPCM audio. Use -i flag for playback control.}
\1\dossynopsis{printfile}[file]{Prints out the contents of a textfile with line numbers. Useful for making descriptive screenshots.} \1\dossynopsis{printfile}[file]{Prints out the contents of a textfile with line numbers. Useful for making descriptive screenshots.}
\1\dossynopsis{touch}[file]{Updates a file's modification date. New file will be created if the specified file does not exist.} \1\dossynopsis{touch}[file]{Updates a file's modification date. New file will be created if the specified file does not exist.}
\1\dossynopsis{true}{Returns errorlevel 0 upon execution.} \1\dossynopsis{true}{Returns errorlevel 0 upon execution.}