1
1
---
2
2
title : CLI
3
+ description : Command Line Interface and running files
3
4
---
4
5
5
- ``` bash
6
+ ``` sh
6
7
$ ags --help
7
8
8
9
USAGE:
@@ -18,7 +19,8 @@ OPTIONS:
18
19
-t, --toggle-window Show or hide a window
19
20
-r, --run-js Execute string as an async function
20
21
-f, --run-file Execute file as an async function
21
- --clear-cache Remove $HOME /.cache/ags
22
+ -I, --init Initialize the configuration directory
23
+ -C, --clear-cache Remove $HOME /.cache/ags
22
24
23
25
```
24
26
@@ -69,8 +71,7 @@ With `--run-js` it is possible to execute code when `ags` is already running.
69
71
It is useful for: calling Service methods, updating Variable values,
70
72
debugging or anything else.
71
73
` --run-js ` expects a string which will be the body of an * async function*
72
- executed relative to ` app.ts ` . This is important because of how you
73
- can import modules inside this function.
74
+ executed relative to ` app.ts ` .
74
75
75
76
If there is no ` ; ` character in the string, ` return ` keyword will be inserted automatically
76
77
@@ -104,36 +105,26 @@ return 'hello from a file'
104
105
```
105
106
106
107
::: info
107
- Since ` --run-js ` is the body of a function, you can't use top level imports
108
+ Since ` --run-js ` is the body of a function, you can't use top level static imports
108
109
:::
109
110
110
- This will throw an error
111
-
112
- ``` js
113
- #! / usr/ bin/ env - S ags -- run- file
114
- import App from ' resource:///com/Aylur/github/ags/app.js'
115
- ```
111
+ ::: important
112
+ The function gets executed relative to ` app.ts ` , which means
113
+ importing a module from your config needs a full path.
114
+ :::
116
115
117
- You can use ` import ` as a method however
116
+ this throws
118
117
119
118
``` js
120
119
#! / usr/ bin/ env - S ags -- run- file
121
- const App = (await import (
122
- ' resource:///com/Aylur/github/ags/app.js' ,
123
- )).default ;
120
+ import Module from ' file:///path/to/file.js' // throws
124
121
```
125
122
126
- ::: tip
127
- The function gets executed relative to ` app.ts ` ,
128
- meaning ` resource:///com/Aylur/github/ags ` can be substituted as ` . `
129
- This also means importing a module from your config needs a full path.
130
- :::
123
+ You can use ` import ` as an ** async** method
131
124
132
125
``` js
133
126
#! / usr/ bin/ env - S ags -- run- file
134
- const App = (await import (' ./app.js' )).default ;
135
-
136
- const File = await import (` file:///path/to/file.js` );
127
+ const Module = (await import (' file:///path/to/file.js' )).default ;
137
128
```
138
129
139
130
## Examples
0 commit comments