Skip to content

Add CLI subcommands and args #142

Open
@applejag

Description

@applejag
Contributor

CLI commands are really useful for doing manual work that we don't want to expose via the web API.

This mostly includes heavy operations, such as data or database migrations.

Suggested CLI

# Start the HTTP server. This is the same as what wharf-api already did in its main before
wharf-api serve

# Migration commands. Low prio, as wharf-api has a decent enough auto-migration on boot
wharf-api migrate latest
wharf-api migrate list
wharf-api migrate rollback "2021-10-05T15:30:00Z-v5.0.0"

# Per-type migration subcommands
wharf-api migrate artifact from s3
wharf-api migrate artifact to s3
wharf-api migrate logs from elasticsearch
wharf-api migrate logs to elasticsearch

# Common flags
wharf-api --version
wharf-api --help
wharf-api --config="my-wharf-api-config.yaml"

Package files move

This means we would have to do some reorganizing in the packages, as most code lies in the main package and main packages cannot be reused by other packages.

Suggest:

main.go            # Runs cmd/root.go
cmd/*.go           # Cobra commands definitions
pkg/serve/serve.go # HTTP endpoints
pkg/data/data.go   # Data access abstraction for reading/writing from Sqlite, Elasticsearch, S3, etc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestprio/0Lowest priority. "Wishful thinking"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @applejag

        Issue actions

          Add CLI subcommands and args · Issue #142 · iver-wharf/wharf-api