gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
896 stars 375 forks source link

contribs/gnok: gnokey but with 33% fewer keystrokes #1590

Open thehowl opened 9 months ago

thehowl commented 9 months ago

An idea for an experimental tool to improve gnokey UX for developer. Can have interactive feature, meant to avoid boilerplate where possible and long-ass commands.

Integrates also the code of gnokeykc to work with the system's keychain.

Ideas:

# make a call to a realm
gnok call r/demo/boards 'CreateThread(123, "Hello world", "Hey, just testing out gnok!")'
# run a query on a realm (same syntax as call)
gnok eval r/demo/boards 'Render("")'
# render a realm with a path
gnok render r/demo/boards testboard 
# deploys directory, with path according to gno.mod present in it or any upper directory
gnok deploy path/to/dir

# gnokey options default to:
# gas-wanted=10e6 (max), remote = local, chainid = dev, key = test1 (automatically added if not present).
# these options can be configured globally, or per-directory. Rather than saving these in a
# .gnokconfig file in the directory, the info for each directory is saved in $GNOHOME/gnok.toml
# 
# set a global (git inspired)
gnok config --global remote test3.gno.land:36657
# set a local config option
gnok config remote test4.gno.land:12345
gnok config key myOtherKey

The specific semantics of local/global config will have to be figured out writing the tool

Is there demand for something like this? :)

waymobetta commented 9 months ago

Would this replace gnokey or is the idea to support two tools? I've been using shell scripts to improve UX.

thehowl commented 9 months ago

Would this replace gnokey or is the idea to support two tools?

For working with http requests in the terminal, the two most used tools are curl and wget. Realistically, when working with anything beyond transferring a file, you would use curl, as its flags and customisation options allow you to do virtually anything. It easily integrates with shell scripts, it is available on a majority of user machines, it does just about everything you could think of in relation to HTTP requests[^1].

But if you're a developer working from the command line, httpie gives you a much faster way to express what you want to do in 99% of cases. (I personally its Go clone as it starts up 30x faster, but I digress). Some people even think Postman is good.

I would see gnokey vs gnok as the same. gnokey is THE tool to access the Gno.land blockchain, and practically you should use it and get acquainted with it first, as nothing that gnok does cannot be done with gnokey. However, most of the time you're still doing only a specific subset of things, and I very often find myself just searching through my zsh history to find old gnokey commands I've used. That is the use case I envision for this tool.

On top of this, note that I did not include, for instance, examples on how to generate bip39 keys, or import/export keys, or many other things that gnokey can do. This is deliberate: if they're rarely used commands anyway, getting a nicer UX for them doesn't serve much of a purpose.

[^1]: though it supports a lot more protocols, I'm just making a metaphor here!

leohhhn commented 5 months ago

This is great. Can we somehow incorporate parts of this into gnokey? I have a related issue here.