Skip to content
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
110 changes: 110 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ sha2 = "0.11"
chrono = { version = "0.4", features = ["serde"] }
url = "2"
dotenvy = "0.15"
tempfile = "3"
rpassword = "7"

[dev-dependencies]
mockito = "1"
insta = "1"

[profile.release]
opt-level = "z"
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ hubstaff config setup-oauth
This will prompt you for a Client ID and Client Secret. To get those:

1. Go to [developer.hubstaff.com](https://developer.hubstaff.com) > OAuth Apps > Create
2. Set the redirect URI to `http://localhost:19876/callback`
2. Set the redirect URI to `http://127.0.0.1:19876/callback`
This must match exactly, and port `19876` must be free when you run `hubstaff login`.
3. Copy the Client ID and Client Secret

Then authenticate:
Expand Down Expand Up @@ -127,6 +128,9 @@ hubstaff config set auth_url URL
hubstaff config set schema_url URL
hubstaff config set token TOKEN
hubstaff config set format compact
hubstaff config unset organization
hubstaff config unset schema_url
hubstaff config reset
hubstaff config set-pat TOKEN
hubstaff config setup-oauth
hubstaff config show
Expand Down Expand Up @@ -154,7 +158,7 @@ On macOS this is typically:
- `~/Library/Application Support/hubstaff/schema/v2/docs.json`
- `~/Library/Application Support/hubstaff/schema/v2/meta.toml`

## Staging / Custom Environments
## Custom Environment

```bash
hubstaff config set api_url <api_url>
Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ install-tools:
command -v cargo-deny >/dev/null || cargo install cargo-deny --locked
command -v cargo-audit >/dev/null || cargo install cargo-audit --locked
command -v cargo-auditable >/dev/null || cargo install cargo-auditable --locked

refresh-schema-fixture:
curl -sSf https://api.hubstaff.com/v2/docs -o tests/fixtures/schema.json
INSTA_UPDATE=auto cargo test schema_command_table_snapshot -- --nocapture
14 changes: 12 additions & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn run_dynamic(
schema: &ApiSchema,
args: &[String],
pretty_json: bool,
organization_override: Option<u64>,
) -> Result<(), CliError> {
let index = CommandIndex::load_or_build(schema)?;
let parsed = ParsedInvocation::parse(args)?;
Expand Down Expand Up @@ -63,7 +64,13 @@ pub fn run_dynamic(
"query options",
)?;

fill_defaults_from_config(operation, client, &mut path_values, &mut query_values)?;
fill_defaults_from_config(
operation,
client,
organization_override,
&mut path_values,
&mut query_values,
)?;
validate_required_parameters(operation, &path_values, &query_values)?;
validate_enum_values(operation, &path_values, ParameterLocation::Path)?;
validate_enum_values(operation, &query_values, ParameterLocation::Query)?;
Expand Down Expand Up @@ -632,6 +639,7 @@ fn validate_known_values(
fn fill_defaults_from_config(
operation: &Operation,
client: &HubstaffClient,
organization_override: Option<u64>,
path_values: &mut HashMap<String, String>,
query_values: &mut HashMap<String, String>,
) -> Result<(), CliError> {
Expand All @@ -654,7 +662,9 @@ fn fill_defaults_from_config(
continue;
}

let organization_id = client.resolve_organization(None)?.to_string();
let organization_id = client
.resolve_organization(organization_override)?
.to_string();
match parameter.location {
ParameterLocation::Path => {
path_values.insert("organization_id".to_string(), organization_id);
Expand Down
Loading
Loading