-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Add JSON input file support, docs (#7709) #8054
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of good things here, one thing I am curious about...
Since this can already be written in a shell script, what is the additional ROI of adding another layering here? I'd be curious your use case / motivation. As this adds additional ways of interacting, it increases the scope of support 😬
@davidiw a couple thoughts:
Your thoughts? |
This was common in the AWS CLI as well. The CLI allowed JSON input, but would also take a whole JSON file that defined all the inputs. Usually providing a JSON input into the CLI even if scripted tends to be messy around escaping. It is a little unfortunate that full JSON is a very verbose path, and this provides yet another level of support needed for it. |
@0xjinn have you been able to successfully run the new functionality using the docs site tutorial preview for this PR? |
Tested from my side using both @alnoki Shall we include the testing json file in the |
Use literal file include for maintainability Update pnpm package spec for literal file include Update dictionary for literal file include See aptos-labs#8054 (comment)
@0xjinn Nice, thanks for confirming both styles.
28cb64d adds JSON files to the example directory per your request. Is there anything else needed to land this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Will let @gregnazario and @davidiw to take a final look on this.
@0xjinn #8346 extends this PR with additional multisig tooling and a comprehensive multisig governance tutorial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, particularly of JSON input from a file. Where I'm less convinced is using JSON for args directly on the CLI, but I don't see the harm of landing this support alongside the existing parsing logic. Saying that, I notice that with this CLI the old way of providing vector arguments no longer works.
Before:
$ aptos move run --function-id 0x1::cli_args::set_vals --args u8:123 'vector<address>:0x1,0x2'
{
"Error": "Simulation failed with status: Transaction Executed and Committed with Error LINKER_ERROR"
}
After:
$ ~/a/core/target/debug/aptos move run --function-id 0x1::cli_args::set_vals --args u8:123 'vector<address>:0x1,0x2'
error: Invalid value "vector<address>:0x1,0x2" for '--args <ARGS>...': Invalid arguments: Invalid arg type 'vector<address>'. Must be one of: ['address','bool','hex','string','u8','u16','u32','u64','u128','u256','raw']
For more information try --help
In my opinion we can't land such a breaking change, the old behavior would have to continue to work in addition to the new behavior.
@banool note that the breaking syntax is necessary to support multi-nested vectors and has already been merged per #7790 This PR just extends the functionality with JSON input files |
Hummm okay I see, all good then! Looks like the docs have been updated correctly too. |
Closed by #8346 |
@0xjinn @gregnazario @davidiw
Summary of changes
TryInto
andTryFrom
implementations in accordance with DRY design principlesJSON syntax
As described in the docs site tutorial preview for this PR, a public entry function can now be invoked with arguments passed from either the CLI or from a JSON file:
Arguments passed via CLI
Arguments passed via JSON file
Command:
JSON file:
The docs site tutorial also includes examples for view functions and script functions.