Skip to content

Commit 5dfe37e

Browse files
authored
Merge pull request #58 from hotdata-dev/feat/auth-login-subcommand
feat(auth): add login subcommand mirroring bare auth
2 parents 73209ea + 5034fb2 commit 5dfe37e

6 files changed

Lines changed: 17 additions & 11 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ cp target/release/hotdata /usr/local/bin/hotdata
3333

3434
## Connect
3535

36-
Run the following command to authenticate:
36+
Run either of the following (they are equivalent):
3737

3838
```sh
39+
hotdata auth login
40+
# or
3941
hotdata auth
4042
```
4143

@@ -60,7 +62,7 @@ API key priority (lowest to highest): config file → `HOTDATA_API_KEY` env var
6062

6163
| Command | Subcommands | Description |
6264
| :-- | :-- | :-- |
63-
| `auth` | `status`, `logout` | Authenticate (run without subcommand to log in) |
65+
| `auth` | `login`, `status`, `logout` | `login` or bare `auth` opens browser login; `status` / `logout` manage the saved profile |
6466
| `workspaces` | `list`, `set` | Manage workspaces |
6567
| `connections` | `list`, `create`, `refresh`, `new` | Manage connections |
6668
| `tables` | `list` | List tables and columns |

skills/hotdata/SKILL.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Or if installed on PATH: `hotdata <command> [args]`
1616

1717
## Authentication
1818

19-
Run `hotdata auth` to authenticate via browser login. Config is stored in `~/.hotdata/config.yml`.
19+
Run **`hotdata auth login`** (or **`hotdata auth`** with no subcommand—same behavior) to authenticate via browser login. Config is stored in `~/.hotdata/config.yml`.
2020

2121
API key resolution (lowest to highest priority):
22-
1. Config file (saved by `hotdata auth`)
22+
1. Config file (saved by `hotdata auth login` / `hotdata auth`)
2323
2. `HOTDATA_API_KEY` environment variable (or `.env` file)
2424
3. `--api-key <key>` flag (works on any command)
2525

@@ -325,7 +325,8 @@ hotdata jobs <job_id> [--workspace-id <workspace_id>] [--output table|json|yaml]
325325

326326
### Auth
327327
```
328-
hotdata auth # Browser-based login
328+
hotdata auth login # Browser-based login (same as: hotdata auth)
329+
hotdata auth # Browser-based login (same as: hotdata auth login)
329330
hotdata auth status # Check current auth status
330331
hotdata auth logout # Remove saved auth for the default profile
331332
```

src/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl ApiClient {
2727
let api_key = match &profile_config.api_key {
2828
Some(key) if key != "PLACEHOLDER" => key.clone(),
2929
_ => {
30-
eprintln!("error: not authenticated. Run 'hotdata auth' to log in.");
30+
eprintln!("error: not authenticated. Run 'hotdata auth login' (or 'hotdata auth') to log in.");
3131
std::process::exit(1);
3232
}
3333
};
@@ -294,7 +294,7 @@ fn format_fail_message(
294294
) -> String {
295295
if status.is_client_error() {
296296
if let Some(auth::AuthStatus::Invalid(_)) = auth_status {
297-
return "error: API key is invalid. Run 'hotdata auth' to re-authenticate.".to_string();
297+
return "error: API key is invalid. Run 'hotdata auth login' (or 'hotdata auth') to re-authenticate.".to_string();
298298
}
299299
}
300300
util::api_error(body.to_string())
@@ -313,7 +313,7 @@ mod tests {
313313
Some(&AuthStatus::Invalid(401)),
314314
);
315315
assert!(msg.contains("API key is invalid"));
316-
assert!(msg.contains("hotdata auth"));
316+
assert!(msg.contains("hotdata auth login") || msg.contains("hotdata auth"));
317317
}
318318

319319
#[test]

src/command.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ pub enum QueryCommands {
236236

237237
#[derive(Subcommand)]
238238
pub enum AuthCommands {
239+
/// Log in via browser (same as `hotdata auth` with no subcommand)
240+
Login,
241+
239242
/// Remove authentication for a profile
240243
Logout,
241244

src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub fn resolve_workspace_id(provided: Option<String>, profile_config: &ProfileCo
266266
.workspaces
267267
.first()
268268
.map(|w| w.public_id.clone())
269-
.ok_or_else(|| "no workspace-id provided and no default workspace found. Run 'hotdata auth' or specify --workspace-id.".to_string())
269+
.ok_or_else(|| "no workspace-id provided and no default workspace found. Run 'hotdata auth login' (or 'hotdata auth') or specify --workspace-id.".to_string())
270270
}
271271

272272
/// Global API key override set via --api-key flag.
@@ -285,7 +285,7 @@ pub fn load(profile: &str) -> Result<ProfileConfig, String> {
285285
fs::read_to_string(&config_file).map_err(|e| format!("error reading config file: {e}"))?;
286286
let config_file: ConfigFile = serde_yaml::from_str(&content).unwrap_or_else(|_| {
287287
eprintln!("{}", "error parsing config file.".red());
288-
eprintln!("Run 'hotdata auth' to generate a new config file.");
288+
eprintln!("Run 'hotdata auth login' (or 'hotdata auth') to generate a new config file.");
289289
std::process::exit(1);
290290
});
291291
config_file.profiles.get(profile).cloned().unwrap_or_default()

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ fn main() {
9292
}
9393
Some(cmd) => match cmd {
9494
Commands::Auth { command } => match command {
95-
None => auth::login(),
95+
None | Some(AuthCommands::Login) => auth::login(),
9696
Some(AuthCommands::Status) => auth::status("default"),
9797
Some(AuthCommands::Logout) => auth::logout("default"),
9898
},

0 commit comments

Comments
 (0)