From eea43305d804eef821e29b0e96a407c94419e972 Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Thu, 5 Nov 2020 12:47:29 -0800 Subject: [PATCH 1/2] Update cli docs generation script --- dev/cli_md_template.md | 19 --------------- dev/generate_cli_md.sh | 48 ++++++++++++++++++++++++++++++-------- docs/guides/windows-cli.md | 2 +- docs/miscellaneous/cli.md | 2 +- 4 files changed, 40 insertions(+), 31 deletions(-) delete mode 100644 dev/cli_md_template.md diff --git a/dev/cli_md_template.md b/dev/cli_md_template.md deleted file mode 100644 index f03da55dde..0000000000 --- a/dev/cli_md_template.md +++ /dev/null @@ -1,19 +0,0 @@ -# CLI commands - -_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_ - -## Install the CLI - -```bash -pip install cortex -``` - -## Install the CLI without Python Client - -```bash -# Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1): -$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)" - -# For example to download CLI version 0.18.1 (Note the 'v'): -$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)" -``` diff --git a/dev/generate_cli_md.sh b/dev/generate_cli_md.sh index c30be6a841..82885222a6 100755 --- a/dev/generate_cli_md.sh +++ b/dev/generate_cli_md.sh @@ -18,10 +18,37 @@ set -e ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)" -cat $ROOT/dev/cli_md_template.md +out_file=$ROOT/docs/miscellaneous/cli.md +rm -f $out_file + +echo '# CLI commands' >> $out_file +echo '' >> $out_file +echo '_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_' >> $out_file +echo '' >> $out_file +echo '## Install the CLI' >> $out_file +echo '' >> $out_file +echo '```bash' >> $out_file +echo 'pip install cortex' >> $out_file +echo '```' >> $out_file +echo '' >> $out_file +echo '## Install the CLI without Python Client' >> $out_file +echo '' >> $out_file +echo '### Mac/Linux OS' >> $out_file +echo '' >> $out_file +echo '```bash' >> $out_file +echo '# Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1):' >> $out_file +echo '$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)"' >> $out_file +echo '' >> $out_file +echo '# For example to download CLI version 0.18.1 (Note the "v"):' >> $out_file +echo '$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)"' >> $out_file +echo '```' >> $out_file +echo '' >> $out_file +echo '### Windows' >> $out_file +echo '' >> $out_file +echo 'To install the Cortex CLI on a Windows machine, follow [this guide](../guides/windows-cli.md).' >> $out_file +echo '' >> $out_file make --no-print-directory -C $ROOT cli -echo # Clear default environments cli_config_backup_path=$HOME/.cortex/cli-bak-$RANDOM.yaml @@ -47,17 +74,18 @@ commands=( "completion" ) -echo "## Command overview" -echo +echo '## Command overview' >> $out_file for cmd in "${commands[@]}"; do - echo "### ${cmd}" - echo - echo -n '```text' - $ROOT/bin/cortex help ${cmd} - echo '```' - echo + echo '' >> $out_file + echo "### ${cmd}" >> $out_file + echo '' >> $out_file + echo -n '```text' >> $out_file + $ROOT/bin/cortex help ${cmd} >> $out_file + echo '```' >> $out_file done # Bring back CLI config mv -f $cli_config_backup_path $HOME/.cortex/cli.yaml + +echo "updated $out_file" diff --git a/docs/guides/windows-cli.md b/docs/guides/windows-cli.md index 99bdd1253b..3f62406152 100644 --- a/docs/guides/windows-cli.md +++ b/docs/guides/windows-cli.md @@ -42,7 +42,7 @@ pip install cortex # Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1): $ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)" -# For example to download CLI version 0.18.1 (Note the 'v'): +# For example to download CLI version 0.18.1 (Note the "v"): $ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)" ``` diff --git a/docs/miscellaneous/cli.md b/docs/miscellaneous/cli.md index 43f22058cf..75b6575050 100644 --- a/docs/miscellaneous/cli.md +++ b/docs/miscellaneous/cli.md @@ -16,7 +16,7 @@ pip install cortex # Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1): $ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)" -# For example to download CLI version 0.18.1 (Note the 'v'): +# For example to download CLI version 0.18.1 (Note the "v"): $ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)" ``` From 54f83c76db9e91572cba6aacced0f1fc1c4b632e Mon Sep 17 00:00:00 2001 From: David Eliahu Date: Mon, 9 Nov 2020 08:28:55 -0800 Subject: [PATCH 2/2] Address PR comment --- dev/cli_md_template.md | 27 +++++++++++++++++++++++++++ dev/generate_cli_md.sh | 32 ++++---------------------------- 2 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 dev/cli_md_template.md diff --git a/dev/cli_md_template.md b/dev/cli_md_template.md new file mode 100644 index 0000000000..ba64d8a21e --- /dev/null +++ b/dev/cli_md_template.md @@ -0,0 +1,27 @@ +# CLI commands + +_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_ + +## Install the CLI + +```bash +pip install cortex +``` + +## Install the CLI without Python Client + +### Mac/Linux OS + +```bash +# Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1): +$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)" + +# For example to download CLI version 0.18.1 (Note the "v"): +$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)" +``` + +### Windows + +To install the Cortex CLI on a Windows machine, follow [this guide](../guides/windows-cli.md). + +## Command overview diff --git a/dev/generate_cli_md.sh b/dev/generate_cli_md.sh index 82885222a6..7992f91131 100755 --- a/dev/generate_cli_md.sh +++ b/dev/generate_cli_md.sh @@ -21,39 +21,15 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)" out_file=$ROOT/docs/miscellaneous/cli.md rm -f $out_file -echo '# CLI commands' >> $out_file -echo '' >> $out_file -echo '_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_' >> $out_file -echo '' >> $out_file -echo '## Install the CLI' >> $out_file -echo '' >> $out_file -echo '```bash' >> $out_file -echo 'pip install cortex' >> $out_file -echo '```' >> $out_file -echo '' >> $out_file -echo '## Install the CLI without Python Client' >> $out_file -echo '' >> $out_file -echo '### Mac/Linux OS' >> $out_file -echo '' >> $out_file -echo '```bash' >> $out_file -echo '# Replace `INSERT_CORTEX_VERSION` with the complete CLI version (e.g. 0.18.1):' >> $out_file -echo '$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/vINSERT_CORTEX_VERSION/get-cli.sh)"' >> $out_file -echo '' >> $out_file -echo '# For example to download CLI version 0.18.1 (Note the "v"):' >> $out_file -echo '$ bash -c "$(curl -sS https://raw.githubusercontent.com/cortexlabs/cortex/v0.18.1/get-cli.sh)"' >> $out_file -echo '```' >> $out_file -echo '' >> $out_file -echo '### Windows' >> $out_file -echo '' >> $out_file -echo 'To install the Cortex CLI on a Windows machine, follow [this guide](../guides/windows-cli.md).' >> $out_file -echo '' >> $out_file - +echo "building cli..." make --no-print-directory -C $ROOT cli # Clear default environments cli_config_backup_path=$HOME/.cortex/cli-bak-$RANDOM.yaml mv $HOME/.cortex/cli.yaml $cli_config_backup_path +cat $ROOT/dev/cli_md_template.md >> $out_file + commands=( "deploy" "get" @@ -74,7 +50,7 @@ commands=( "completion" ) -echo '## Command overview' >> $out_file +echo "running help commands..." for cmd in "${commands[@]}"; do echo '' >> $out_file