summaryrefslogtreecommitdiff
path: root/docs/ags/cli-app.md
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-09-07 13:00:42 +0000
committerAylur <[email protected]>2024-09-07 13:00:42 +0000
commit13b6c88dd090bfc8997a2916f0c0cc44bdce2c74 (patch)
tree119e7b61b4b63a05ca96cb3f53ef01f44acdb9bb /docs/ags/cli-app.md
parent758550f320af6eca24674032b98679017db582a0 (diff)
docs: touchups
* code block langs * ags faq * fix broken links
Diffstat (limited to 'docs/ags/cli-app.md')
-rw-r--r--docs/ags/cli-app.md38
1 files changed, 21 insertions, 17 deletions
diff --git a/docs/ags/cli-app.md b/docs/ags/cli-app.md
index e647fbf..ceed56a 100644
--- a/docs/ags/cli-app.md
+++ b/docs/ags/cli-app.md
@@ -2,7 +2,7 @@
`App` is a singleton **instance** of [Astal.Application](https://aylur.github.io/libastal/class.Application.html).
-```tsx
+```ts
import { App } from "astal"
```
@@ -29,7 +29,7 @@ You can not instantiate widgets outside of the main function.
You can run multiple instance by defining a unique instance name.
-```tsx
+```ts
App.start({
instanceName: "my-instance", // defaults to "astal"
main() {},
@@ -52,16 +52,20 @@ App.start({
})
```
-```bash
-# ags cli
-$ ags -m "say hi"
-hi cli
+:::code-group
-# astal cli
-$ astal say hi
-hi cli
+```sh [ags]
+ags -m "say hi"
+# hi cli
```
+```sh [astal]
+astal say hi
+# hi cli
+```
+
+:::
+
If you want to run arbitrary JavaScript from cli, you can use `App.eval`.
It will evaluate the passed string as the body of an `async` function.
@@ -76,19 +80,19 @@ App.start({
If the string does not contain a semicolon, a single expression is assumed and returned implicity.
-```bash
-$ ags -m "'hello'"
-hello
+```sh
+ags -m "'hello'"
+# hello
```
If the string contains a semicolon, you have to return explicitly
-```bash
-$ ags -m "'hello';"
-undefined
+```sh
+ags -m "'hello';"
+# undefined
-$ ags -m "return 'hello';"
-hello
+ags -m "return 'hello';"
+# hello
```
## App without AGS