Skip to content

Commit df6b177

Browse files
committed
Improving documentation and adding differentiation for unix and Windows users
1 parent 79fce44 commit df6b177

File tree

1 file changed

+158
-68
lines changed

1 file changed

+158
-68
lines changed

docs/docs/examples.md

Lines changed: 158 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,153 +2,243 @@
22

33
## CLI Example Usage
44

5-
### **1. Install QFieldCloud SDK**
5+
Here it is typical user story, for **Bash** (Linux/macOS) and **PowerShell** (Windows):
66

7-
To interact with the QFieldCloud API, start by installing the official QFieldCloud SDK:
7+
### **Install QFieldCloud SDK**
88

9-
```bash
9+
To interact with the QFieldCloud API, start by installing the official QFieldCloud SDK. The installation command is the same for both Bash and PowerShell:
10+
11+
```shell
1012
pip install qfieldcloud-sdk
1113
```
1214

1315
Once installed, you're ready to manage your projects directly from the command line.
16+
> Note: All values are enclosed in quotes, with single quotes (`'`) recommended for Bash (_but not mandatory_) and double quotes (`"`) for PowerShell.
1417
15-
### **2. Log in to QFieldCloud and Create a New Project**
18+
### **Log in to QFieldCloud and Create a New Project**
1619

1720
First, log in to your QFieldCloud account.
18-
Note that all values are enclosed in single or double quote characters, depending on your operating system's shell.
1921

20-
```bash
21-
qfieldcloud-cli login "ninjamaster" "secret_password123"
22-
```
22+
=== ":material-linux: Linux"
23+
24+
```bash
25+
qfieldcloud-cli login 'ninjamaster' 'secret_password123'
26+
```
27+
28+
=== ":material-microsoft-windows: Windows"
29+
30+
```powershell
31+
qfieldcloud-cli login "ninjamaster" "secret_password123"
32+
```
2333

2434
After signing in, the QFieldCloud CLI will output the value of the authentication token.
2535
The authentication token will be sent to QFieldCloud API to authorize you instead of sending the username and password.
2636
You can explicitly pass the authentication token via passing `--token` CLI argument for every command.
37+
2738
The easier approach is to set an environment variable with your token:
2839

29-
```bash
30-
export QFIELDCLOUD_TOKEN="123abcXYZ987exampleToken"
31-
```
40+
=== ":material-linux: Linux"
41+
42+
```bash
43+
export QFIELDCLOUD_TOKEN='123abcXYZ987exampleToken'
44+
```
45+
46+
=== ":material-microsoft-windows: Windows"
47+
48+
```powershell
49+
$env:QFIELDCLOUD_TOKEN = "123abcXYZ987exampleToken"
50+
```
3251

3352
#### Create a project
3453

35-
Create a project called "Tree_Survey" within your organization:
54+
Create a project called `Tree_Survey` within your organization:
3655

37-
```bash
38-
qfieldcloud-cli create-project --owner "My_Organization_Clan" --description "Daily work project" --is-private "Tree_Survey"
39-
```
56+
=== ":material-linux: Linux"
57+
58+
```bash
59+
qfieldcloud-cli create-project --owner 'My_Organization_Clan' --description 'Daily work project' --is-private 'Tree_Survey'
60+
```
61+
62+
=== ":material-microsoft-windows: Windows"
63+
64+
```powershell
65+
qfieldcloud-cli create-project --owner "My_Organization_Clan" --description "Daily work project" --is-private "Tree_Survey"
66+
```
4067

4168
The project is now created in your QFieldCloud organization, and its project ID (e.g., `123e4567-e89b-12d3-a456-426614174000`) is returned.
4269
You’re now ready for file uploads.
4370

44-
### **3. Upload Local Files to QFieldCloud**
71+
### **Upload Local Files to QFieldCloud**
4572

46-
Prepare your local project files and upload them to QFieldCloud. For example, if your files are located in `/home/ninjamaster/QField/cloud/Tree_survey`:
73+
Prepare your local project files and upload them to QFieldCloud:
4774

48-
```bash
49-
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "/home/ninjamaster/QField/cloud/Tree_survey"
50-
```
75+
=== ":material-linux: Linux"
76+
77+
```bash
78+
qfieldcloud-cli upload-files '123e4567-e89b-12d3-a456-426614174000' '/home/ninjamaster/QField/cloud/Tree_survey'
79+
```
80+
81+
=== ":material-microsoft-windows: Windows"
82+
83+
```powershell
84+
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\QField\cloud\Tree_survey"
85+
```
5186

5287
You can also upload specific files by using the `--filter` option. For instance, to upload only `.gpkg` files:
5388

54-
```bash
55-
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "/home/ninjamaster/QField/cloud/Tree_survey" --filter "*.gpkg"
56-
```
89+
=== ":material-linux: Linux"
5790

58-
### **4. Schedule and Trigger a Package Job**
91+
```bash
92+
qfieldcloud-cli upload-files '123e4567-e89b-12d3-a456-426614174000' '/home/ninjamaster/QField/cloud/Tree_survey' --filter '*.gpkg'
93+
```
5994

60-
Suppose your company packages the project every morning at 8:47 AM. You can automate this process using a cron job:
95+
=== ":material-microsoft-windows: Windows"
6196

62-
```bash
63-
47 8 * * * qfieldcloud-cli job-trigger "123e4567-e89b-12d3-a456-426614174000" package
64-
```
97+
```powershell
98+
qfieldcloud-cli upload-files "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\QField\cloud\Tree_survey" --filter "*.gpkg"
99+
```
65100

66-
This command triggers the package job daily at the specified time. Here's what the cron job format means:
101+
### **Schedule and Trigger a Package Job**
67102

68-
- `47`: Minute (47th minute).
69-
- `8`: Hour (8 AM).
70-
- `*`: Every day of the month.
71-
- `*`: Every month.
72-
- `*`: Every day of the week.
103+
Suppose your company packages the project every morning at 8:47 AM.:
73104

74-
To manually trigger a package job at any time:
105+
=== ":material-linux: Linux"
75106

76-
```bash
77-
qfieldcloud-cli job-trigger "123e4567-e89b-12d3-a456-426614174000" package
78-
```
107+
```bash
108+
47 8 * * * qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package
109+
```
79110

80-
You can force the job to re-run even if one is already queued:
111+
This triggers the package job daily at the specified time. For more information about [cronjob](https://crontab.guru/)
81112

82-
```bash
83-
qfieldcloud-cli job-trigger "123e4567-e89b-12d3-a456-426614174000" package --force
84-
```
113+
=== ":material-microsoft-windows: Windows"
114+
115+
```powershell
116+
schtasks /create /tn "QFieldCloud Job Trigger" /tr "qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package" /sc daily /st 08:47
117+
```
118+
119+
This triggers the package job daily at the specified time. For more information about [schtasks](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks)
120+
121+
To manually trigger a package job at any time and force if require:
85122

86-
### **5. Monitor Job Status**
123+
=== ":material-linux: Linux"
124+
125+
```bash
126+
qfieldcloud-cli job-trigger '123e4567-e89b-12d3-a456-426614174000' package --force
127+
```
128+
129+
=== ":material-microsoft-windows: Windows"
130+
131+
```powershell
132+
qfieldcloud-cli job-trigger "123e4567-e89b-12d3-a456-426614174000" package --force
133+
```
134+
135+
### **Monitor Job Status**
87136

88137
After triggering a job, monitor its status to ensure successful completion:
89138

90-
```bash
91-
qfieldcloud-cli list-jobs "123e4567-e89b-12d3-a456-426614174000" --type package
92-
qfieldcloud-cli job-status "321e4567-e89b-12d3-a456-426614174987"
93-
```
139+
=== ":material-linux: Linux"
140+
141+
```bash
142+
qfieldcloud-cli list-jobs '123e4567-e89b-12d3-a456-426614174000' --type package
143+
qfieldcloud-cli job-status '321e4567-e89b-12d3-a456-426614174987'
144+
```
94145

95-
### **6. Download Files for Backup**
146+
=== ":material-microsoft-windows: Windows"
147+
148+
```powershell
149+
qfieldcloud-cli list-jobs "123e4567-e89b-12d3-a456-426614174000" --type package
150+
qfieldcloud-cli job-status "321e4567-e89b-12d3-a456-426614174987"
151+
```
152+
153+
### **Download Files for Backup**
96154

97155
Once the package job is complete, download the project files for backup. To download all files or filter specific ones (e.g., `.jpg` files):
98156

99-
```bash
100-
qfieldcloud-cli package-download "123e4567-e89b-12d3-a456-426614174000" "/home/ninjamaster/backup_folder/DCIM/2024-11-10/" --filter "*.jpg"
101-
```
157+
=== ":material-linux: Linux"
158+
159+
```bash
160+
qfieldcloud-cli package-download '123e4567-e89b-12d3-a456-426614174000' '/home/ninjamaster/backup_folder/DCIM/2024-11-10/' --filter '*.jpg'
161+
```
162+
163+
=== ":material-microsoft-windows: Windows"
164+
165+
```powershell
166+
qfieldcloud-cli package-download "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\backup_folder\DCIM\2024-11-10\" --filter "*.jpg"
167+
```
102168

103169
If files already exist locally and you want to overwrite them, use the `--force-download` option:
104170

105-
```bash
106-
qfieldcloud-cli package-download "123e4567-e89b-12d3-a456-426614174000" "/home/ninjamaster/backup_folder/DCIM/2024-11-10/" --force-download
107-
```
171+
=== ":material-linux: Linux"
172+
173+
```bash
174+
qfieldcloud-cli package-download '123e4567-e89b-12d3-a456-426614174000' '/home/ninjamaster/backup_folder/DCIM/2024-11-10/' --force-download
175+
```
176+
177+
=== ":material-microsoft-windows: Windows"
108178

109-
### **7. Delete Files to Save Space**
179+
```powershell
180+
qfieldcloud-cli package-download "123e4567-e89b-12d3-a456-426614174000" "C:\Users\ninjamaster\backup_folder\DCIM\2024-11-10\" --force-download
181+
```
182+
183+
### **Delete Files to Save Space**
110184

111185
To free up storage on QFieldCloud, you can delete unnecessary files, such as `.jpg` files:
112186

113-
```bash
114-
qfieldcloud-cli delete-files "123e4567-e89b-12d3-a456-426614174000" --filter "*.jpg"
115-
```
187+
=== ":material-linux: Linux"
188+
189+
```bash
190+
qfieldcloud-cli delete-files '123e4567-e89b-12d3-a456-426614174000' --filter '*.jpg'
191+
```
192+
193+
=== ":material-microsoft-windows: Windows"
194+
195+
```powershell
196+
qfieldcloud-cli delete-files "123e4567-e89b-12d3-a456-426614174000" --filter "*.jpg"
197+
```
116198

117199
You can also delete specific files by specifying their exact path:
118200

119-
```bash
120-
qfieldcloud-cli delete-files "123e4567-e89b-12d3-a456-426614174000" DCIM/tree-202411202334943.jpg
121-
```
201+
=== ":material-linux: Linux"
202+
203+
```bash
204+
qfieldcloud-cli delete-files '123e4567-e89b-12d3-a456-426614174000' 'DCIM/tree-202411202334943.jpg'
205+
```
206+
207+
=== ":material-microsoft-windows: Windows"
208+
209+
```powershell
210+
qfieldcloud-cli delete-files "123e4567-e89b-12d3-a456-426614174000" "DCIM\tree-202411202334943.jpg"
211+
```
122212

123213
### **Other Useful QFieldCloud CLI Commands**
124214

125215
#### **List Your Projects**
126216

127217
To list all projects associated with your account:
128218

129-
```bash
219+
```shell
130220
qfieldcloud-cli list-projects
131221
```
132222

133223
To include public projects in the list:
134224

135-
```bash
225+
```shell
136226
qfieldcloud-cli list-projects --include-public
137227
```
138228

139229
#### **List Files in a Project**
140230

141231
To view all files in a specific project:
142232

143-
```bash
233+
```shell
144234
qfieldcloud-cli list-files "123e4567-e89b-12d3-a456-426614174000"
145235
```
146236

147237
#### **Delete a Project**
148238

149239
To permanently delete a project (be cautious—this action cannot be undone):
150240

151-
```bash
241+
```shell
152242
qfieldcloud-cli delete-project "123e4567-e89b-12d3-a456-426614174000"
153243
```
154244

@@ -158,18 +248,18 @@ You can add, remove, or change the roles of collaborators on your project.
158248

159249
- **Add a Collaborator:**
160250

161-
```bash
251+
```shell
162252
qfieldcloud-cli collaborators-add "123e4567-e89b-12d3-a456-426614174000" "ninja007" admin
163253
```
164254

165255
- **Remove a Collaborator:**
166256

167-
```bash
257+
```shell
168258
qfieldcloud-cli collaborators-remove "123e4567-e89b-12d3-a456-426614174000" "ninja007"
169259
```
170260

171261
- **Change a Collaborator’s Role:**
172262

173-
```bash
263+
```shell
174264
qfieldcloud-cli collaborators-patch "123e4567-e89b-12d3-a456-426614174000" "ninja001" editor
175265
```

0 commit comments

Comments
 (0)