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

Command restructure #124

Closed
sideninja opened this issue Mar 29, 2021 · 7 comments
Closed

Command restructure #124

sideninja opened this issue Mar 29, 2021 · 7 comments
Assignees
Labels
Feature A new user feature or a new package API Feedback

Comments

@sideninja
Copy link
Member

sideninja commented Mar 29, 2021

Commands could be restructured and improved.

Commands should also be autocompleted to avoid typing every time. Cobra has a good support for this https://github.com/spf13/cobra#generating-shell-completions

Possible command restructure for CLI:

Accounts

Nothing really changes here.

accounts get
accounts create
accounts staking-info

Contracts

A new section which I think makes sense because contract is a concept expected from other blockchains to be separated from accounts and I think if we put it in the first level command it will be more visible to users how to deploy contract (I saw this question 2 times already - how to deploy a contract - oh it's under accounts).

contracts deploy
contracts update
contracts remove

Transactions

Nothing really changes here.
Maybe provide a short option for transactions to be tx, although this will also be improved with autocompletions.

transactions send
transactions get

possible shorthand:

tx send
tx get

Keys

Nothing really changes here.

keys generate
keys decode

Project

Adding project manipulation methods. I strongly believe this is a must. Also Bjartek said mulitple times and opened a PR on add contract but this goes further, we should allow adding all resources to the config via command.

project init
project deploy
project add <account|contract|deployment|network>
project remove <account|contract|deployment|network>**  

There should also be a guided prompt way to add resources, let me give an example:

project add deployment
Contracts in the configuration:
[0] FungibleToken
[1] Kibble
[2] KibbleMarket
Choose the contract for deployment: 1

Networks in the configuration:
[0] Emulator
[1] Testnet
[2] Mainnet
Choose the network for deployment: 1

✅ Contract **Kibble** will be deployed to **Testnet** when you run **flow project deploy**

Top Level Commands

Maybe we can flatten commands that have only 1 subcommand either in the following format:

get-block
get-collection
start-emulator
execute-script

or maybe with the following format - where singular verb is actual top level command

block
collection
emulator
script

example
block 120025 (would fetch that block)
@sideninja sideninja added Feature A new user feature or a new package API Feedback labels Mar 29, 2021
@sideninja sideninja self-assigned this Mar 29, 2021
This was referenced Mar 29, 2021
@bjartek
Copy link
Collaborator

bjartek commented Mar 29, 2021

I would prefer the nested form and not the flattend one. Makes tab completion easier.

Also short hand aliases are not much effort to put in and is so nice.

Transaction=tx like you suggested is good.

@bjartek
Copy link
Collaborator

bjartek commented Mar 29, 2021

Are you familiar with how kubectl work here? I would look there for inspiration.

@sideninja
Copy link
Member Author

Are you familiar with how kubectl work here? I would look there for inspiration.

Yep, I did. I think with tab completions it makes sense to not shorten it as new subcommands might be added which would break the structure down the line

@sideninja
Copy link
Member Author

sideninja commented Apr 1, 2021

Update on restructuring.

Init

Initialization shouldn't be part of project subcommand as config is used from other CLI commands too. It should be put in the top level as flow init.

However, this opens few more questions. As flow init is the top command it's now hard to find a place for commands that modify the configuration. One idea is to create top-level config command and have subcommands for modifying config such as:

config add <account|contract|deployment|network>
config remove <account|contract|deployment|network>
config init (aliased with flow init) 

This flow init alias also opens a new door of having frequent commands aliased and improve UX and make it pretty.

Maybe aliases commands could even be separated in help section so it could look like:

Usage:
  flow [command]

Hot Commands:
  init       Initialize configuration
  deploy     Deploy contracts
  run        Start emulator and deploy contracts

Available Commands:
  accounts     Utilities to manage accounts
  blocks       Utilities to read blocks
  cadence      Execute Cadence code
  collections  Utilities to read collections
  emulator     Starts the Flow emulator server
  events       Utilities to read events
  help         Help about any command
  keys         Utilities to manage keys
  project      Manage your Cadence project
  scripts      Utilities to execute scripts
  transactions Utilities to send transactions
  version      View version and commit information
  config       Configuration commands

@bjartek
Copy link
Collaborator

bjartek commented Apr 2, 2021

Looks great to me :)

@psiemens
Copy link
Contributor

psiemens commented Apr 5, 2021

@sideninja I really like this proposed structure now that I'm seeing it written down.

The config subcommand group makes a lot of sense to me 👍

@bluesign
Copy link
Collaborator

bluesign commented Apr 24, 2021

I am using like this long time (just copy pasted default generator code from (https://github.com/spf13/cobra/blob/master/shell_completions.md), so I have some comments.

Variables are not showing up (ex: flow accounts get address), I think can be related to making it required parameter maybe, I didn't have much time to check.

Also some global flags should not show I guess (for example: --network on flow keys generate)

https://asciinema.org/a/d9scOA3BmlGdxhQwgJOSZoGNN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new user feature or a new package API Feedback
Projects
None yet
Development

No branches or pull requests

4 participants