Content deleted Content added
No edit summary Tags: Reverted Mobile edit Mobile web edit |
m remove extraneous characters from perl code sample |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1:
{{short description|Programming languages parsing of command-line arguments}}
Different '''command-line argument parsing''' methods are used by different [[programming languages]] to [[parse]] [[command-line argument]]s.
==Programming languages==
Line 13:
{
int count;
for (count = 0; count < argc; count++)
puts (argv[count]);
}
Line 66:
<syntaxhighlight lang="perl">
foreach $arg (@ARGV)
{
print $arg;
}
</syntaxhighlight>
or
<syntaxhighlight lang="perl">
foreach $argnum (0 .. $#ARGV)
{
print $ARGV[$argnum];
Line 186:
</syntaxhighlight>
===
====Node.js====
[[JavaScript]] programs written for [[Node.js]] use the <code>process.argv</code> global variable.<ref>{{cite web|title=process.argv|work=Node.js v10.16.3 Documentation|url=https://nodejs.org/docs/latest-v10.x/api/process.html#process_process_argv|accessdate=3 October 2019}}</ref>
Line 218 ⟶ 219:
'two=three',
'four' ]
</syntaxhighlight>
====Bun====
JavaScript written for [[Bun (software)|Bun]] use <code>Bun.argv</code> and the <code>util.parseArgs</code> function.<ref>{{cite web |title=Parse command-line arguments {{!}} Bun Examples |url=https://bun.sh/guides/process/argv |website=Bun |language=en}}</ref>
<syntaxhighlight lang="javascript">
console.log(Bun.argv);
</syntaxhighlight>
====Deno====
JavaScript written for [[Deno (software)|Deno]] use <code>Deno.args</code><ref>{{cite web |title=Deno.args |url=https://docs.deno.com/api/deno/~/Deno.args |website=docs.deno.com}}</ref> and the <code>parseArgs</code> function.<ref>{{cite web |title=parseArgs from parse-args - @std/cli - JSR |url=https://jsr.io/@std/cli/doc/parse-args/~/parseArgs |website=jsr.io |language=en}}</ref>
<syntaxhighlight lang="javascript">
console.log(Deno.args);
</syntaxhighlight>
|