Skip to content

Conversation

@shreyb
Copy link
Collaborator

@shreyb shreyb commented Apr 18, 2025

Reordered pre-FerryCLI steps so that they are:

  1. Parse our auth args
  2. Set up the credential
  3. Check for --update flag
  4. Check to see if we have other args and DON'T have the --update flag set

Tests are in the comments below.

@shreyb
Copy link
Collaborator Author

shreyb commented Apr 18, 2025

Checks:

$ bin/ferry-cli --update
Fetching latest swagger file...
Successfully stored latest swagger file.

No more arguments provided. Exiting.

And now with post-actions:

$ bin/ferry-cli --update -e getUserInfo --username me
Fetching latest swagger file...
Successfully stored latest swagger file.

{
    "ferry_status": "success",
    "ferry_error": [],
    "ferry_output": {
        "banned": false,
        "expirationdate": "2038-01-01T00:00:00Z",
VARIOUS REDACTED INFO
    },
    "request_url": "REDACTED"
}

And now with no --update, and no args either:

$ bin/ferry-cli 
Configuration file already exists at /home/sbhat/.config/ferry_cli/config.ini. Are you sure you want to overwrite it (Y/[n])?  n
A configuration file is required to run the Ferry CLI. Please run "ferry-cli" to generate one interactively if one does not already exist.
usage: ferry-cli [-h] [-a AUTH_METHOD] [--token-path TOKEN_PATH | --cert-path CERT_PATH] [--ca-path CA_PATH] [--dryrun | -d | -q] [-u] [--support_email] [--version]
                 [--output OUTPUT] [--filter FILTER] [-le] [-lw] [-ep ENDPOINT_PARAMS] [-wp WORKFLOW_PARAMS] [-e ENDPOINT] [-w WORKFLOW] [--show-config-file]

CLI for Ferry API endpoints

optional arguments:
  -h, --help            show this help message and exit
  -a AUTH_METHOD, --auth-method AUTH_METHOD
                        Auth method for FERRY request
  --token-path TOKEN_PATH
                        Path to bearer token
  --cert-path CERT_PATH
                        Path to cert
  --ca-path CA_PATH     Certificate authority path
  --dryrun              Populate the API call(s) but don't actually run them
  -d, --debug           Turn on debugging
  -q, --quiet           Hide output
  -u, --update          Get latest swagger file
  --support_email       Get Ferry CLI support emails
  --version             Get Ferry CLI version
  --output OUTPUT       (string) Specifies the path to a file where the output will be stored in JSON format. If a file already exists in the specified path, it will be
                        overritten.
  --filter FILTER       (string) Use to filter results on -le and -lw flags
  -le, --list_endpoints, --list-endpoints
                        List all available endpoints
  -lw, --list_workflows, --list-workflows
                        List all supported custom workflows
  -ep ENDPOINT_PARAMS, --endpoint_params ENDPOINT_PARAMS, --endpoint-params ENDPOINT_PARAMS
                        List parameters for the selected endpoint
  -wp WORKFLOW_PARAMS, --workflow_params WORKFLOW_PARAMS, --workflow-params WORKFLOW_PARAMS
                        List parameters for the supported workflow
  -e ENDPOINT, --endpoint ENDPOINT
                        API endpoint and parameters
  -w WORKFLOW, --workflow WORKFLOW
                        Execute supported workflows
  --show-config-file    Locate and print configuration file, if it exists, then exit.
Exiting without writing configuration file.

shreyb added 2 commits April 17, 2025 21:34
print_help will bypass most of the class instantiation and simply print
help from the FerryCLI.get_arg_parser()

authorizer passes in the Auth subclass that will be used to authorize
the FerryCLI queries
@shreyb
Copy link
Collaborator Author

shreyb commented Apr 18, 2025

Cleaned up the code a little bit:

I added two new optional arguments to the FerryCLI class instantiation: print_help and authorizer

print_help will bypass most of the class instantiation and simply print help from the FerryCLI.get_arg_parser(), then return

authorizer passes in the Auth subclass that will be used to authorize the FerryCLI queries

@shreyb shreyb added this to the 1.0.2 milestone Apr 18, 2025
@shreyb shreyb linked an issue Apr 18, 2025 that may be closed by this pull request
@shreyb shreyb requested review from LTrestka and cathulhu April 18, 2025 02:40
Copy link
Collaborator

@cathulhu cathulhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quite sensible changes.

@shreyb shreyb merged commit cfca9d1 into master May 7, 2025
1 check passed
@LTrestka LTrestka deleted the issue-101 branch September 16, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug if we try to use an auth_arg like --update, but no other args

3 participants