Skip to content

Commit 02dbbd3

Browse files
committed
Update README
1 parent 5e29b71 commit 02dbbd3

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,57 @@ Uninstall a plugin using the following command:
5959
```shell
6060
$ pba-cli plugin uninstall <plugin name>
6161
```
62+
63+
### Custom scripts
64+
65+
To create a custom script that registers in the CLI, create an executable anywhere on your `PATH` that follows the naming convention `minimal-pba-cli-<name>`.
66+
This script will be registered as a command named `<name>` in the CLI.
67+
68+
As an example, create a script named `minimal-pba-cli-hello` with the following content:
69+
70+
```shell
71+
#!/usr/bin/env sh
72+
73+
echo "Hello, world!"
74+
```
75+
76+
Make the script executable:
77+
78+
```shell
79+
$ chmod +x minimal-pba-cli-hello
80+
```
81+
82+
Now, if the script is located in a directory on your `PATH`, you can run it using the following command:
83+
84+
```shell
85+
$ pba-cli hello
86+
Hello, world!
87+
```
88+
89+
Scripts can be written in any language, as long as they are executable and follow the naming convention:
90+
91+
```python
92+
#!/usr/bin/env python
93+
94+
# minimal-pba-cli-quote
95+
96+
import json
97+
import urllib.request
98+
99+
100+
if __name__ == "__main__":
101+
response = urllib.request.urlopen("https://zenquotes.io/api/random")
102+
data = json.loads(response.read().decode("utf-8"))
103+
print(f"""
104+
"{data[0]['q']}"
105+
106+
- {data[0]['a']}
107+
```
108+
109+
```shell
110+
$ pba-cli quote
111+
112+
"Educating the mind without educating the heart is no education at all."
113+
114+
- Aristotle
115+
```

0 commit comments

Comments
 (0)