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

[CLI] Adding StructOpt to Leo binary #584

Closed
damirka opened this issue Jan 28, 2021 · 1 comment
Closed

[CLI] Adding StructOpt to Leo binary #584

damirka opened this issue Jan 28, 2021 · 1 comment
Assignees
Labels
feature A new feature. refactor Refactor or cleanup.

Comments

@damirka
Copy link
Contributor

damirka commented Jan 28, 2021

💥 Proposal

Motivation

One of our goals is to make CLI environment safer and more stable as it is the entry point into language. Better architecture can help achieve this goal and save time implementing features or debugging unexpected behaviors.

  • StructOpt simplifies argument descriptions and shortens the code.
  • Anyhow simplifies error handling in general and allows focusing on features.

Architecture

I have mocked up the basic structure of proposed changes: https://github.com/damirka/leo/blob/leo-ref/leo

In detail:

  • cmd context can help accessing common package info such as manifest or setting path
  • common API module should follow Aleo PM swagger and is a single place for working with PM
  • anyhow used everywhere to handle errors and for common error handler as well
  • StructOpt params are defined for each command and are well documented

Compatibility

This is only reorganization, not a refactoring. Every command can be simply placed into new Cmd wrappers with its arguments specified. So no functionality is going to be lost in the process. You can run examples from the repo and see that they work (1) and contain the same code as current Leo CLI.

StructOpt is Clap but better on definitions.

Estimates

Should take about 2 days to copy-paste commands and do some cosmetics and docs.

What it brings

It also creates space for future optimizations such as putting manifest into context, having common handlers and structures for APIs and makes code more readable and upgradable.

@damirka damirka added feature A new feature. refactor Refactor or cleanup. labels Jan 28, 2021
@damirka damirka self-assigned this Jan 28, 2021
damirka added a commit that referenced this issue Feb 8, 2021
Features:

- introduces new Command and Route traits for Leo commands and Aleo PM API
- most of the CLI code replace with higher-level abstraction - StructOpt
- anyhow used for error handling, no more custom error classes
- improves API - now every status code has its business logic
- adds global flags (e.g. --quiet to suppress output)
- error messages improved for convenience and better user experience

Closes:

- #604
- #599
- #584
- #277
- #376
@collinc97
Copy link
Collaborator

Closed by #632

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature. refactor Refactor or cleanup.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants