Skip to content

Commit bf1dc81

Browse files
committed
update readme, docs, install sripts, and more
1 parent 5f52d50 commit bf1dc81

File tree

8 files changed

+162
-67
lines changed

8 files changed

+162
-67
lines changed

README.md

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
[![License Apache2](https://img.shields.io/hexpm/l/plug.svg)](http://www.apache.org/licenses/LICENSE-2.0)
44
![Latest Release](https://img.shields.io/badge/release-1.0.0.beta-orange)
55

6-
Astra CLI provides a command line interface in a terminal to operate DataStax Astra. The goal is to offer access to any feature without accessing the user interface.
6+
Astra CLI provides a terminal interface to operate DataStax Astra. The goal is to offer access to any feature without accessing the user interface.
7+
8+
![Astra CLI MacOS demo](assets/demo.gif)
79

810
> This is the README for the new 1.0.0 (beta) version of the Astra CLI. See the README for the previous version [here](https://github.com/datastax/astra-cli/tree/0.x?tab=readme-ov-file#astra-cli).
911
@@ -18,8 +20,8 @@ Astra CLI provides a command line interface in a terminal to operate DataStax As
1820
- [Customization](#customization)
1921
- [Home folder location](#home-folder-location)
2022
- [`.astrarc` location](#astrarc-location)
21-
- [Response format](#response-format)
22-
- [Output level](#output-level)
23+
- [Output format](#output-format)
24+
- [Output style](#output-style)
2325
- [What's new](#whats-new)
2426
- [Windows support](#windows-support)
2527
- [Improved output and interactivity](#improved-output-and-interactivity)
@@ -83,7 +85,7 @@ You can also download a specific version, or the latest prerelease version, usin
8385

8486
```bash
8587
# Upgrade (or downgrade!) to a specific version
86-
astra upgrade --version 1.0.0-rc-2
88+
astra upgrade --version 1.0.0-rc.4
8789

8890
# Upgrade to the latest prerelease version
8991
astra upgrade --pre
@@ -120,7 +122,7 @@ After installation, run `astra setup` to interactively set up your credentials i
120122
astra setup
121123
```
122124

123-
The `astra config` subcommands can be further used to manager your configuration profiles.
125+
The `astra config` subcommands can be further used to manage your configuration profiles.
124126

125127
### Using the CLI without a credentials file
126128

@@ -145,18 +147,18 @@ astra db list --token <your_token> [--env <your_env>]
145147
146148
### Home folder location
147149
148-
The Astra CLI uses a singular home folder to store various data, such as downloaded programs, secure connect bundles, completions caches, etc.
150+
The Astra CLI uses a single home folder to store various data, such as downloaded programs, secure connect bundles, completions caches, etc.
149151
150152
By default, this folder is located at either `$XDG_DATA_HOME/astra` (if the `XDG_DATA_HOME` environment variable is set), or at `~/.astra` (if not).
151153
152154
You can override this location by setting the `ASTRA_HOME` environment variable to your desired path.
153155
154156
```bash
155-
# Possible
156-
echo 'export ASTRA_HOME=/path/to/your/astra/home' >> ~/.bashrc
157+
# Option 1: Set the environment variable directly
158+
echo 'export ASTRA_HOME=/path/to/your/astra/home' >> ~/.bash_profile
157159
158-
# Preferred
159-
echo 'eval "$(astra shellenv --home "/path/to/your/astra/home")"' >> ~/.bashrc
160+
# Option 2: Use shellenv (preferred, as it handles shell-specific setup)
161+
echo 'eval "$(astra shellenv --home "/path/to/your/astra/home")"' >> ~/.bash_profile
160162
```
161163
162164
### `.astrarc` location
@@ -168,11 +170,11 @@ By default, this file is located at either `$XDG_CONFIG_HOME/astra/.astrarc` (if
168170
You can override this location by setting the `ASTRARC` environment variable to your desired path.
169171

170172
```bash
171-
# Possible
172-
echo 'export ASTRARC=/path/to/your/.astrarc' >> ~/.bashrc
173+
# Option 1: Set the environment variable directly
174+
echo 'export ASTRARC=/path/to/your/.astrarc' >> ~/.bash_profile
173175

174-
# Preferred
175-
echo 'eval "$(astra shellenv --rc "/path/to/your/.astrarc")"' >> ~/.bashrc
176+
# Option 2: Use shellenv (preferred, as it handles shell-specific setup)
177+
echo 'eval "$(astra shellenv --rc "/path/to/your/.astrarc")"' >> ~/.bash_profile
176178
```
177179

178180
### Output format
@@ -565,6 +567,14 @@ Some commands, namely the ones that build on `cqlsh`, `dsbulk`, and `pulsar-shel
565567

566568
<details>
567569
<summary><strong>pulsar-shell</strong></summary>
570+
571+
Similar to `cqlsh` and `dsbulk`, the pulsar-shell commands have been organized under the `astra streaming pulsar` subcommand.
572+
573+
The available commands include:
574+
- `astra streaming pulsar shell` – Launch an interactive Apache Pulsar shell session for a streaming tenant
575+
- Supports `-e <statement>` and `-f <file>` flags for non-interactive execution
576+
- `astra streaming pulsar version` – Prints the version of `pulsar-shell` that is used by the CLI
577+
- `astra streaming pulsar path` – Prints the path to the `pulsar-shell` binary, installing it if necessary
568578
</details>
569579

570580
### XDG spec compliance
@@ -575,18 +585,63 @@ The Astra CLI will now respect the `$XDG_DATA_HOME` and `$XDG_CONFIG_HOME` envir
575585

576586
<details>
577587
<summary>Other minor changes (not exhaustive)</summary>
578-
<li> automatically patch cqlsh script to work on machines with a newer python version as default by testing for older python versions explicitly
579-
<li> consistent support of the `--output` flag across all commands–either a format is supported, or the command will error out before doing anything
580-
<li> removed `astra-init` script in favor of the `astra compgen` command
581-
<li> removed `astra login` since it was just an alias of `astra setup`
582-
<li> `setup` command has been completely rewritten and improved to be much more interactive and user-friendly
583-
<li> fewer API calls will be made due to better internal caching and logic (commands may be much faster now!)
584-
<li> fixed inconsistent shell coloring in places (--no-color now definitively works everywhere)
585-
<li> fixed issues with not being able to use IDs in place of names in some places (e.g. `db delete [id]`)
586-
<li> timeout durations can now be parsed using iso8601 durations or with simple time units (ms, s, m, h)
587-
<li> .astrarc parsing is stricter now
588-
<li> improved .env + .ini parsing + printing
589-
<li> and more.
588+
<ul>
589+
<li>automatically patch cqlsh script to work on machines with a newer python version as default by testing for older python versions explicitly</li>
590+
<li>consistent support of the `--output` flag across all commands–either a format is supported, or the command will error out before doing anything</li>
591+
<li>removed `astra-init` script in favor of the `astra compgen` command</li>
592+
<li>removed `astra login` since it was just an alias of `astra setup`</li>
593+
<li>`setup` command has been completely rewritten and improved to be much more interactive and user-friendly</li>
594+
<li>fewer API calls will be made due to better internal caching and logic (commands may be much faster now!)</li>
595+
<li>fixed inconsistent shell coloring in places (--no-color now definitively works everywhere)</li>
596+
<li>fixed issues with not being able to use IDs in place of names in some places (e.g. `db delete [id]`)</li>
597+
<li>timeout durations can now be parsed using iso8601 durations or with simple time units (ms, s, m, h)</li>
598+
<li>.astrarc parsing is stricter now</li>
599+
<li>improved .env + .ini parsing + printing</li>
600+
<li>and more.</li>
601+
</ul>
590602
</details>
591603

592604
## Troubleshooting
605+
606+
### Common issues
607+
608+
**MacOS security warnings**
609+
610+
If you get an "unidentified developer" error on macOS, see the [macOS warning section](#-macos-warning) above.
611+
612+
**Authentication failures**
613+
614+
If commands fail with authentication errors:
615+
- Verify your token is valid and hasn't expired
616+
- Check that you're using the correct environment (`--env` flag)
617+
- Run `astra config list` to verify your configuration profile settings
618+
- Try running `astra setup` again to reconfigure your credentials
619+
620+
**External programs not working (cqlsh, dsbulk, pulsar-shell)**
621+
622+
If external programs fail to download or execute:
623+
- Check your internet connection
624+
- Verify you have write permissions to your `ASTRA_HOME` directory
625+
- Try removing the cached binary and letting the CLI re-download it:
626+
```bash
627+
# Find the path first
628+
astra db cqlsh path # (or dsbulk path, or streaming pulsar path)
629+
# Then remove the parent directory and try again
630+
```
631+
632+
**Finding your configuration files**
633+
634+
If you're unsure where your `.astrarc` file or home folder is located, or if you're getting warnings about multiple paths:
635+
- Run `astra config path` to see where your `.astrarc` file is (or would be) located
636+
- Run `astra config home path` to see where your Astra home folder is located
637+
- If you see warnings about multiple `.astrarc` files or home folders existing in different locations:
638+
- Remove or migrate the lower priority files/folders (priority: custom env var > XDG spec > default home directory)
639+
- Or, suppress the warning by setting `ASTRA_IGNORE_MULTIPLE_PATHS=true`
640+
641+
**General debugging**
642+
643+
For any issues:
644+
- Use the `--verbose` flag to see detailed output
645+
- Use the `--dump-logs` flag to save logs to a file for later inspection
646+
- Check the [GitHub issues](https://github.com/datastax/astra-cli/issues) for similar problems
647+
- Open a new issue if your problem isn't already reported

assets/demo.gif

897 KB
Loading

scripts/install.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ if (-not $existingInstallPath -and (Test-Path (Join-Path $ASTRA_CLI_DIR "astra.e
187187
if ($existingInstallPath) {
188188
Write-Host ""
189189
Write-Host "Error: An existing astra installation was already found." -ForegroundColor Red
190-
Write-Host "An existing installation was found at $(Tildify (Split-Path $existingInstallPath))`n"
190+
Write-Host "An existing installation was found at $( Tildify (Split-Path $existingInstallPath) )`n"
191191
Write-MultiColor -Texts @("-> ", "(< astra-cli 1.x)", " Remove the existing installation manually and re-run this installer.") -Colors @("DarkCyan", "DarkGray", "Gray")
192192
Write-MultiColor -Texts @("-> ", "(> astra-cli 1.x)", " Run ", "astra upgrade", " to automatically update to the latest version.") -Colors @("DarkCyan", "DarkGray", "Gray", "DarkCyan", "Gray")
193193
Write-MultiColor -Texts @("-> ", "(> astra-cli 1.x)", " Run ", "astra nuke", " to completely remove the CLI and then re-run this installer.") -Colors @("DarkCyan", "DarkGray", "Gray", "DarkCyan", "Gray")
@@ -200,7 +200,7 @@ if ($existingInstallPath) {
200200

201201
# Create installation directory
202202
New-Item -ItemType Directory -Force -Path $ASTRA_CLI_DIR | Out-Null
203-
Checklist "Using installation dir $($ASTRA_CLI_DIR + "\")"
203+
Checklist "Using installation dir $( $ASTRA_CLI_DIR + "\" )"
204204

205205
# Download and extract
206206
$zipPath = Join-Path $ASTRA_CLI_DIR "astra-tmp.zip"
@@ -224,7 +224,7 @@ catch {
224224
}
225225
catch {
226226
Remove-Item $zipPath -ErrorAction SilentlyContinue
227-
Panic "`nError: Failed to download the archive to $(Tildify $zipPath). Check your internet connection and permissions."
227+
Panic "`nError: Failed to download the archive to $( Tildify $zipPath ). Check your internet connection and permissions."
228228
}
229229
}
230230

@@ -244,7 +244,7 @@ try {
244244
Remove-Item -Recurse -Force $tempDir
245245
}
246246
catch {
247-
Panic "`nError: Failed to extract the archive at $(Tildify $zipPath)."
247+
Panic "`nError: Failed to extract the archive at $( Tildify $zipPath )."
248248
}
249249
finally {
250250
Remove-Item -Force $zipPath -ErrorAction SilentlyContinue

scripts/install.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ RESET=$(color sgr0)
7272

7373
# Prelude
7474
echo "$PURPLE"
75-
echo " _____ __ "
76-
echo " / _ \ _______/ |_____________ "
77-
echo " / /_\ \ / ___/\ __\_ __ \__ \ "
78-
echo " / | \\___ \ | | | | \// __ \_ "
79-
echo " \____|__ /____ > |__| |__| (____ / "
80-
echo " \/ \/ \/ "
75+
echo " _____ __ "
76+
echo " / _ \ _______/ |_____________ "
77+
echo " / /_\ \ / ___/\ __\_ __ \__ \ "
78+
echo " / | \\___ \ | | | | \// __ \_ "
79+
echo " \____|__ /____ > |__| |__| (____ / "
80+
echo " \/ \/ \/ "
8181
echo ""
8282
echo " Installer: $ASTRA_CLI_VERSION"
8383
echo "$RESET"
@@ -122,7 +122,7 @@ print_next_steps() {
122122
echo ""
123123
fi
124124

125-
renderComment "Append the following to your shell profile (e.g. $(underline "~/.bashrc"), $(underline "~/.zshrc"), etc.)"
125+
renderComment "Append the following to your shell profile (e.g. $(underline "~/.zprofile"), $(underline "~/.bash_profile"), etc.)"
126126
if [ "$ASTRA_CLI_DIR_RESOLVER" = "custom" ]; then
127127
renderCommand "eval \"\$($(tildify "$EXE_PATH") shellenv --home \"$(tildify "$ASTRA_HOME")\")\""
128128
else

scripts/uninstall.ps1

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ try {
9090
} catch {
9191
# Try a second time
9292
Stop-Astra
93-
Start-Sleep -Seconds 1
93+
Start-Sleep -Seconds 3
9494
try {
9595
Remove-Item "${PSScriptRoot}\astra.exe" -Force
9696
} catch {
@@ -126,18 +126,6 @@ if (Test-Path "${AstraHome}") {
126126
}
127127
}
128128

129-
# Determine .astrarc location
130-
if ($env:ASTRARC) {
131-
$AstraRc = $env:ASTRARC
132-
} elseif ($env:XDG_CONFIG_HOME) {
133-
$AstraRc = "$env:XDG_CONFIG_HOME\astra\.astrarc"
134-
} else {
135-
$AstraRc = "$HOME\.astrarc"
136-
}
137-
138-
# Remove .astrarc file (do not fail if it doesn't exist)
139-
Remove-Item "${AstraRc}" -Force -ErrorAction SilentlyContinue
140-
141129
# Remove Entry from PATH
142130
try {
143131
$currentPath = Get-Env -Key 'Path'

src/main/java/com/dtsx/astra/cli/commands/ShellEnvCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
" @|blue:300 *|@ Enable shell completions",
3030
" @|blue:300 *|@ Optionally set any other configuration environment variables.",
3131
"",
32-
"Intended to be added to your shell profile (@|code .zshrc|@, @|code .zprofile|@, @|code .bashrc|@, etc.), but you can technically just eval it in any shell session to get completions and update your PATH for that session.",
32+
"Intended to be added to your shell profile (@|code .zprofile|@, @|code .bash_profile|@, @|code .profile|@, etc.), but you can technically just eval it in any shell session to get completions and update your PATH for that session.",
3333
},
3434
descriptionHeading = "%n"
3535
)

src/main/java/com/dtsx/astra/cli/commands/config/ConfigPathCmd.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.dtsx.astra.cli.operations.config.ConfigPathOperation;
99
import com.dtsx.astra.cli.operations.config.ConfigPathOperation.ConfigPathResult;
1010
import lombok.val;
11+
import org.jetbrains.annotations.Nullable;
12+
import picocli.CommandLine.ArgGroup;
1113
import picocli.CommandLine.Command;
1214
import picocli.CommandLine.Option;
1315

@@ -21,29 +23,53 @@
2123
name = "path",
2224
description = {
2325
"Prints the expected path of the .astrarc file, even if does not exist.",
24-
"Checks @|code ASTRARC|@ @|faint,italic (ASTRARC=~/my_folder/.my_rc)|@ -> @|code XDG_CONFIG_HOME|@ @|faint,italic ($XDG_CONFIG_HOME/astra/.astrarc)|@ -> @|code HOME|@ @|faint,italic (~/.astrarc)|@.",
26+
"",
27+
"The file is resolved in the following order:",
28+
" @|blue:300 1.|@ The @|code ASTRARC|@ environment variable @|faint,italic (e.g. ASTRARC=~/my_folder/.my_rc)|@",
29+
" @|blue:300 2.|@ The @|code XDG_CONFIG_HOME|@ spec @|faint,italic (e.g. $XDG_CONFIG_HOME/astra/.astrarc)|@",
30+
" @|blue:300 3.|@ The default home directory @|faint,italic (e.g. ~/.astrarc)|@",
31+
"",
32+
"By default, shows informational output when running in a TTY (interactive terminal), and plain path output when piped or redirected."
2533
}
2634
)
2735
@Example(
2836
comment = "Get information about the path to the .astrarc file",
2937
command = "${cli.name} config path"
3038
)
3139
@Example(
32-
comment = "Print only the path to the .astrarc file, without additional information",
40+
comment = "Force only the plain path to the .astrarc file, without additional information",
3341
command = "${cli.name} config path -p"
3442
)
43+
@Example(
44+
comment = "Force informational output even when piped or redirected",
45+
command = "${cli.name} config path -i"
46+
)
3547
public class ConfigPathCmd extends AbstractCmd<ConfigPathResult> {
36-
@Option(
37-
names = { "-p", "--plain" },
38-
description = "Print only the path to the .astrarc file, without additional information"
39-
)
40-
public boolean pathOnly;
48+
@ArgGroup
49+
public @Nullable OutputMode outputMode;
50+
51+
public static class OutputMode {
52+
@Option(
53+
names = { "-p", "--plain" },
54+
description = "Print only the path to the .astrarc file, without additional information (always)"
55+
)
56+
public boolean pathOnly;
57+
58+
@Option(
59+
names = { "-i", "--info" },
60+
description = "Print informational output with context about the path (always)"
61+
)
62+
public boolean info;
63+
}
4164

4265
@Override
4366
protected OutputAll execute(Supplier<ConfigPathResult> res) {
4467
val data = mkData(res.get());
4568

46-
if (pathOnly) {
69+
val pathOnly = outputMode != null && outputMode.pathOnly;
70+
val info = outputMode != null && outputMode.info;
71+
72+
if (pathOnly || (!info && ctx.isNotTty())) {
4773
return OutputAll.response(res.get().path(), data);
4874
}
4975

0 commit comments

Comments
 (0)