From ab31a0a198e65090d6a4e9e411bad4446f3b6d8e Mon Sep 17 00:00:00 2001 From: Andrii Bodnar Date: Fri, 29 Mar 2024 16:51:39 +0200 Subject: [PATCH] docs: exit codes article (#757) --- website/docs/ci-cd.md | 1 + website/docs/exit-codes.md | 32 ++++++++++++++++++++++++++++++++ website/sidebars.js | 19 ++++++++++--------- 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 website/docs/exit-codes.md diff --git a/website/docs/ci-cd.md b/website/docs/ci-cd.md index 07cb6aaa..d1c45b40 100644 --- a/website/docs/ci-cd.md +++ b/website/docs/ci-cd.md @@ -55,3 +55,4 @@ jobs: ## Further Reading - [Commands](/commands/crowdin) +- [Exit Codes](/exit-codes) diff --git a/website/docs/exit-codes.md b/website/docs/exit-codes.md new file mode 100644 index 00000000..fadd771f --- /dev/null +++ b/website/docs/exit-codes.md @@ -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. diff --git a/website/sidebars.js b/website/sidebars.js index b0d5fe99..73216220 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -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', @@ -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', ], };