forked from Mirror/wren
Add API for accessing command-line arguments.
- Add process module with Process class. - Add "arguments" and "allArguments" methods. - Docs for same. - Support passing additional arguments to command line. - Add "--help" support to command line.
This commit is contained in:
@ -44,5 +44,6 @@ applications that want to embed Wren.
|
||||
[libuv]: http://libuv.org
|
||||
|
||||
* [io](io)
|
||||
* [process](process)
|
||||
* [scheduler](scheduler)
|
||||
* [timer](timer)
|
||||
|
||||
5
doc/site/modules/process/index.markdown
Normal file
5
doc/site/modules/process/index.markdown
Normal file
@ -0,0 +1,5 @@
|
||||
^title Module "process"
|
||||
|
||||
The process module exposes a single class for working with operating processes.
|
||||
|
||||
* [Process](process.html)
|
||||
38
doc/site/modules/process/process.markdown
Normal file
38
doc/site/modules/process/process.markdown
Normal file
@ -0,0 +1,38 @@
|
||||
^title Process Class
|
||||
|
||||
The Process class lets you work with operating processes, including the
|
||||
currently running one.
|
||||
|
||||
## Static Methods
|
||||
|
||||
### **allArguments**
|
||||
|
||||
The list of command-line arguments that were passed when the Wren process was
|
||||
spawned. This includes the Wren executable itself, the path to the file being
|
||||
run (if any), and any other options passed to Wren itself.
|
||||
|
||||
If you run:
|
||||
|
||||
:::bash
|
||||
$ wren file.wren arg
|
||||
|
||||
This returns:
|
||||
|
||||
:::wren
|
||||
System.print(Process.allArguments) //> ["wren", "file.wren", "arg"]
|
||||
|
||||
### **arguments**
|
||||
|
||||
The list of command-line arguments that were passed to your program when the
|
||||
Wren process was spawned. This does not include arguments handled by Wren
|
||||
itself.
|
||||
|
||||
If you run:
|
||||
|
||||
:::bash
|
||||
$ wren file.wren arg
|
||||
|
||||
This returns:
|
||||
|
||||
:::wren
|
||||
System.print(Process.arguments) //> ["arg"]
|
||||
74
doc/site/modules/process/template.html
Normal file
74
doc/site/modules/process/template.html
Normal file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
|
||||
<title>{title} – Wren</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css" />
|
||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic|Source+Code+Pro:400|Lato:400|Sanchez:400italic,400' rel='stylesheet' type='text/css'>
|
||||
<!-- Tell mobile browsers we're optimized for them and they don't need to crop
|
||||
the viewport. -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
|
||||
</head>
|
||||
<body id="top" class="module">
|
||||
<header>
|
||||
<div class="page">
|
||||
<div class="main-column">
|
||||
<h1><a href="../../">wren</a></h1>
|
||||
<h2>a classy little scripting language</h2>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="page">
|
||||
<nav class="big">
|
||||
<ul>
|
||||
<li><a href="../">Modules</a></li>
|
||||
<li><a href="./">process</a></li>
|
||||
</ul>
|
||||
<section>
|
||||
<h2>process classes</h2>
|
||||
<ul>
|
||||
<li><a href="process.html">Process</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</nav>
|
||||
<nav class="small">
|
||||
<table>
|
||||
<tr>
|
||||
<td><a href="../">Modules</a></td>
|
||||
<td><a href="./">process</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><h2>process classes</h2></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="process.html">Process</a></li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</nav>
|
||||
<main>
|
||||
<h1>{title}</h1>
|
||||
{html}
|
||||
</main>
|
||||
</div>
|
||||
<footer>
|
||||
<div class="page">
|
||||
<div class="main-column">
|
||||
<p>Wren lives
|
||||
<a href="https://github.com/munificent/wren">on GitHub</a>
|
||||
— Made with ❤ by
|
||||
<a href="http://journal.stuffwithstuff.com/">Bob Nystrom</a> and
|
||||
<a href="https://github.com/munificent/wren/blob/master/AUTHORS">friends</a>.
|
||||
</p>
|
||||
<div class="main-column">
|
||||
</div>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@ -37,6 +37,7 @@
|
||||
<h2>cli</h2>
|
||||
<ul>
|
||||
<li><a href="io">io</a></li>
|
||||
<li><a href="process">process</a></li>
|
||||
<li><a href="scheduler">scheduler</a></li>
|
||||
<li><a href="timer">timer</a></li>
|
||||
</ul>
|
||||
@ -64,6 +65,7 @@
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="io">io</a></li>
|
||||
<li><a href="process">process</a></li>
|
||||
<li><a href="scheduler">scheduler</a></li>
|
||||
<li><a href="timer">timer</a></li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user