Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: exit codes article #757

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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