Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unified tremor binary #200

Closed
Licenser opened this issue Apr 28, 2020 · 1 comment · Fixed by #422
Closed

unified tremor binary #200

Licenser opened this issue Apr 28, 2020 · 1 comment · Fixed by #422
Assignees
Labels
enhancement New feature or request

Comments

@Licenser
Copy link
Member

Licenser commented Apr 28, 2020

Describe the problem you are trying to solve

We currently have 4 command-line tools that people need to keep in mind, switch between, and build separately. This can be burdensome and confusing.

Describe the solution you'd like

Combine all the tools into a single binary. This will make it easy for the user to use tremor and have the binary handy.

The concept of a singular binary is popular in the go ecosystem and well perceived in tools like docker & friends so it's a well-accepted practice.

Notes

This supersedes #7 and #8.

A draft of the CLI:

# tremor-script --pre-process script.tremor         => tremor dbg highlight --pre-process script.tremor
# tremor-script -s script.tremor                    => tremor dbg highlight script.tremor
# tremor-script -l script.tremor                    => tremor dbg lex script.tremor
# tremor-script -a script.tremor                    => tremor dbg ast --highlight script.tremor
# tremor-script -r script.tremor                    => tremor dbg ast script.tremor
# tremor-script --process script.tremor             => tremor run script.tremor
# tremor-script -e file.json script.tremor          => cat file.json | tremor-tool run script.tremor
#                                                   => tremor-tool run -i file.json script.tremor
# tremor-script --string "[1,2]" script.tremor      => echo "[1,2]" | tremor-tool run script.tremor
# tremor-script -e file.json -o error script.tremor => cat file.json | tremor-tool run --port err script.tremor
#
# tremor-query -p script.trickle                    => tremor dbg highlight --pre-process script.trickle
# tremor-query -s script.trickle                    => tremor dbg highlight script.trickle
# tremor-query -l script.trickle                    => tremor dbg lex script.trickle
# tremor-query -a script.trickle                    => tremor dbg ast --highlight script.trickle
# tremor-query -r script.trickle                    => tremor dbg ast script.trickle
# NEW                                               => tremor run script.trickle
# tremor-query -e file.json script.trickle          => cat file.json | tremor-tool run script.trickle
#                                                   => tremor-tool run -i file.json script.trickle
# tremor-query --string "[1,2]" script.trickle      => echo "[1,2]" | tremor-tool run script.trickle
# tremor-query -e file.json -o error script.trickle => cat file.json | tremor-tool run --port err script.trickle
#
# tremor-server -c f.yml f2.yml -q query.trickle    => tremor server -f f.yml f2.yml query.trickle

#
# Concept:
#  1) rare / more developper focused commands are in the `dbg` sub command
#  2) server commands are behind the `server` sub scommand.
#  3) local commands are behind `run` and detect script/query based on file extnesions
#  4) api commands are behind `api`
---
name: tremor
version: "0.8"
author: The Tremor Team
about: Tremor
settings:
  - ArgRequiredElseHelp
args:
  - verbose:
      short: v
      multiple: true
      help: Sets the level of verbosity
subcommands:
  - server:
      about: Tremor server
      args:
        loaded-files:
          help: Pipelines, onramps, etc to load
          short: f
          takes_value: true
          min_values: 1
          max_values: 10000
        no-api:
          help: Disable the API
          takes_value: false
          short: n
          long: no-api
        api-host:
          help: Listening host for the API
          short: h
          long: api-host
        instance:
          help: Instance identifier
          short: i
          long: instance
        logger-config:
          help: log4rs config
          short: l
          long: logger-config
  - dbg:
      about: Advanced debugging commands
      subcommands:
        - highlight:
            about: Highlights a trickle or script file
            args:
              pre-process:
                help: Prints the preprocessed source instead of the original
                short: p
                long: pre-process
        - ast:
            about: prints the ast of the file
            args:
              - SCRIPT:
                  help: tremor script filename
                  required: true
              - highlight:
                  help: highlight output
                  short: h
                  long: no-highlight
        - lex:
            about: prints output of the lexer
            args:
              - SCRIPT:
                  help: tremor script filename
                  required: true
              - no-highlight:
                  help: do not highlight output
                  short: n
                  long: no-highlight
  - run:
      about: >
        Run tremor script and query files against stdin or a json data archive,
        the data will be read from STDIN and written to STDOUT.
      args:
        - SCRIPT:
            help: filename to run the data through
            required: true
        - ENCODER:
            short: e
            long: encoder
            help: The codec to use for encoding the data
            default_value: json
        - DECODER:
            short: d
            long: decoder
            help: The codec to use for decoding the data
            default_value: json
        - INFILE:
            help: input file
            short: i
            takes_value: true
            default_value: "-"
        - OUTFILE:
            help: output file
            short: o
            takes_value: true
            default_value: "-"
        - PREPROCESSOR:
            long: pre-processor
            multiple: true
            help: preprocessor to pass data through before decoding
            default_value: lines
        - POSTPROCESSOR:
            long: post-processor
            multiple: true
            help: postprocessor to pass data through after encoding
        - output-port:
            long: port
            short: p
            help: selects the port to pull output
  - api:
      about: Tremor API client
      args:
        - format:
            short: f
            multiple: false
            help: Sets the output format
            possible_values: [json, yaml]
            takes_value: true
        - config:
            short: c
            long: config
            value_name: FILE
            help: Sets a custom config file
            takes_value: true
      subcommands:
        - version:
            about: Get tremor version
        - target:
            about: Target one or many tremor server instances
            subcommands:
              - list:
                  about: List registered targets
              - create:
                  about: Create a new API target
                  args:
                    - TARGET_ID:
                        help: The unique target id for the targetted tremor servers
                        required: true
                    - SOURCE:
                        help: JSON or YAML file request body
                        required: true
              - delete:
                  about: Delete an existing API target
                  args:
                    - TARGET_ID:
                        help: The unique target id for the targetted tremor servers
                        required: true
        - binding:
            about: Query/update binding specification repository
            subcommands:
              - list:
                  about: List registered binding specifications
              - fetch:
                  about: Fetch a binding by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the binding specification
                        required: true
              - delete:
                  about: Delete a binding by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the binding specification
                        required: true
              - create:
                  about: Create and register a binding specification
                  args:
                    - SOURCE:
                        help: JSON or YAML file request body
                        required: true
              - instance:
                  about: Fetch an binding instance by artefact id and instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the binding specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the binding specification
                        required: true
              - activate:
                  about: Activate a binding by artefact id and servant instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the binding specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the binding specification
                        required: true
                    - SOURCE:
                        help: JSON -r YAML file request body
                        required: true
              - deactivate:
                  about: Activate a binding by artefact id and servant instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the binding specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the binding specification
                        required: true
        - pipeline:
            about: Query/update pipeline specification repository
            subcommands:
              - list:
                  about: List registered pipeline specifications
              - fetch:
                  about: Fetch a pipeline by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the pipeline specification
                        required: true
              - delete:
                  about: Delete a pipeline by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the pipeline specification
                        required: true
              - create:
                  about: Create and register a pipeline specification
                  args:
                    - SOURCE:
                        help: JSON or YAML file request body
                        required: false
              - instance:
                  about: Fetch an pipeline instance by artefact id and instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the pipeline specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the pipeline specification
                        required: true
        - onramp:
            about: Query/update onramp specification repository
            subcommands:
              - list:
                  about: List registered onramp specifications
              - fetch:
                  about: Fetch an onramp by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the onramp specification
                        required: true
              - delete:
                  about: Delete an onramp by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the onramp specification
                        required: true
              - create:
                  about: Create and register an onramp specification
                  args:
                    - SOURCE:
                        help: JSON or YAML file request body
                        required: false
              - instance:
                  about: Fetch an onramp instance by artefact id and instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the onramp specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the onramp specification
                        required: true
        - offramp:
            about: Query/update offramp specification repository
            subcommands:
              - list:
                  about: List registered offramp specifications
              - fetch:
                  about: Fetch an offramp by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the offramp specification
                        required: true
              - delete:
                  about: Delete an offramp by artefact id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the offramp specification
                        required: true
              - create:
                  about: Create and register an offramp specification
                  args:
                    - SOURCE:
                        help: JSON or YAML file request body
                        required: false
              - instance:
                  about: Fetch an offramp instance by artefact id and instance id
                  args:
                    - ARTEFACT_ID:
                        help: The unique artefact id for the offramp specification
                        required: true
                    - INSTANCE_ID:
                        help: The unique instance id for the offramp specification
                        required: true
@darach
Copy link
Member

darach commented Apr 30, 2020

Ensure required/optional parameters are correctly specified to avoid bugs such as #206 perhaps by extending EQC tests to fuzz test command line interactions based on the cli clap yaml as drafted above.

@darach darach mentioned this issue Sep 10, 2020
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants