Skip to content

Commit

Permalink
docs: exit codes article (#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar authored Mar 29, 2024
1 parent bd66a66 commit ab31a0a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
1 change: 1 addition & 0 deletions website/docs/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ jobs:
## Further Reading

- [Commands](/commands/crowdin)
- [Exit Codes](/exit-codes)
32 changes: 32 additions & 0 deletions website/docs/exit-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Exit Codes

Crowdin CLI provides exit codes to help users understand the results of their operations. Exit codes are numeric values returned by commands executed in the terminal, indicating the success or failure of the operation. These codes can be especially useful when scripting or automating tasks with Crowdin CLI.

| Exit code | Explanation |
|-----------|----------------|
| 0 | Success |
| 1 | Error occurred |

:::tip
Help us improve the list of CLI exit codes. If you have any suggestions or ideas, [let us know 💡](https://github.com/crowdin/crowdin-cli/discussions/756)
:::

## Handling Exit Codes

When scripting or automating tasks with Crowdin CLI, it's important to handle exit codes appropriately to ensure robustness and error handling. You can use these exit codes in conditional statements to perform specific actions based on the result of the command execution. Here's an example in a shell script:

```bash
#!/bin/bash

# Run Crowdin CLI command
crowdin upload sources

# Check the exit code
if [ $? -eq 0 ]; then
echo "Upload completed successfully."
else
echo "Upload failed. Exit code: $?"
fi
```

In this script, the `crowdin upload sources` command is executed, and then the exit code is checked. If the exit code is `0`, it prints a success message; otherwise, it prints a failure message along with the exit code.
19 changes: 10 additions & 9 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const sidebars = {
'intro',
'installation',
'configuration',
{
type: 'category',
label: 'Tutorials',
collapsible: true,
collapsed: false,
items: [
'tutorials/files-management',
]
},
{
type: 'category',
label: 'Commands',
Expand Down Expand Up @@ -252,17 +261,9 @@ const sidebars = {
'commands/crowdin-pre-translate',
],
},
{
type: 'category',
label: 'Tutorials',
collapsible: true,
collapsed: false,
items: [
'tutorials/files-management',
]
},
'ci-cd',
'advanced',
'exit-codes',
'faq',
],
};
Expand Down

0 comments on commit ab31a0a

Please sign in to comment.