-
Notifications
You must be signed in to change notification settings - Fork 121
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
Improved CLI #287
Improved CLI #287
Conversation
@vitorpy Hey, nice initiative! But adding oclif is a bit too much as it's a full-blown suite for making CLIs and it implicitly brings over its structure layout. This could've been the issue with the tests failing to find If you want to change the current argument parser library from Additionally, when it comes to |
Cool - I haven't seen
Yeah, that's why I started to look into this. I wanted to look at FunC outputs (and from there to Fift outputs). |
I think it's ok to work on the |
Hey @vitorpy, do you think we can still manage do this CLI improvement before 1.3.0 release? Btw, I think we could also add |
Yes, let's aim for the 1.3 release. I should have some time this weekend to look into this. I'll add |
@novusnota Hey, can you take a look? I haven't test this yet, but I want to make sure you're OK with the approach. If you're OK with the approach, I'll give it some testing, work out the kinks and publish this PR. |
@vitorpy if you rename And seems like you forgot to add the |
@novusnota Oh, thanks! I thought it wouldn't be OK to rename the tact bin. It looks so much cleaner now. I kinda feel config_path should be an argument (being always required) but since a breaking change in the binary syntax doesn't make sense, I re-introduced the |
Ah,
This is now a redundant step in the GitHub workflow, as the version from |
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.
Really nice!
We should also add some CLI tests to CI. At least one test per each CLI flag to demonstrate it it's there. You can put the data you need in this folder: https://github.com/tact-lang/tact/tree/main/test/tact-cli |
@vitorpy Lots of improvements in this PR! |
Co-authored-by: Anton Trunov <[email protected]>
Co-authored-by: Anton Trunov <[email protected]>
@novusnota Something went wrong with single-contract compilation, which works as expected. Here is a shell session with ❯ ls
tact.config.json test.tact
tact/contract new-cli* ≡
❯ cat tact.config.json
{
"$schema": "http://raw.githubusercontent.com/tact-lang/tact/main/grammar/configSchema.json",
"projects": [
{
"name": "test",
"path": "./test.tact",
"output": "./",
"mode": "funcOnly"
}
]
}
tact/contract new-cli* ≡
❯ cat test.tact
contract Foo {
get fun foo(): Int {
return 42;
}
}
tact/contract new-cli* ≡
❯ ../bin/tact --config tact.config.json
💼 Compiling project test...
> Foo: tact compiler
✔️ FunC code generation succeeded.
tact/contract new-cli* ≡
❯ ls
tact.config.json test_Foo.abi test_Foo.headers.fc test_Foo.storage.fc
test.tact test_Foo.code.fc test_Foo.stdlib.fc And here is a shell session with single-contract compilation with the same contract and and ❯ rm -f *.abi *.boc *.fc *.fif *.pkg *.md *.ts
tact/contract new-cli* ≡
❯ ls
tact.config.json test.tact
tact/contract new-cli* ≡
❯ ../bin/tact --func test.tact
💼 Compiling project main...
> 👀 Enabling debug
> Foo: tact compiler
> Foo: func compiler
> Foo: fift decompiler
> Packaging
> Foo
> Bindings
> Foo
> Reports
> Foo
tact/contract new-cli* ≡
❯ ls
main_Foo.abi main_Foo.code.fif main_Foo.md main_Foo.storage.fc test.tact
main_Foo.code.boc main_Foo.code.rev.fif main_Foo.pkg main_Foo.ts
main_Foo.code.fc main_Foo.headers.fc main_Foo.stdlib.fc tact.config.json It does not stop after generating FunC files. |
@anton-trunov hmm, can't reproduce that error, my UPD: I may have found a bigger source of potential bugs — bin/tact depends on src/node.ts, not on dist/node.js. Fixing this now. |
@novusnota Yes, I'm on commit 0b18c8c. I can reproduce it after |
To me this sounds backwards. Why do you need to reverse the dependency? |
No changes there, just a "read issue" :) UPD: Found out the reason (enum over disjoint values messed up the CLI schema a bit), now working on solution |
Separated the two in a more distinct way to reduce possible errors
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.
Just one thing that is left: it's a de facto standard that more local flags should have priority over less local ones. Here how it fails for bin/tact
:
❯ cat tact.config.json
{
"$schema": "http://raw.githubusercontent.com/tact-lang/tact/main/grammar/configSchema.json",
"projects": [
{
"name": "test",
"path": "./test.tact",
"output": "./",
"mode": "full"
}
]
}
tact/contract new-cli* ≡
❯ ../bin/tact --config tact.config.json --check
💼 Compiling project test...
> Foo: tact compiler
> Foo: func compiler
> Foo: fift decompiler
> Packaging
> Foo
> Bindings
> Foo
> Reports
> Foo
It is expected that the CLI flag --check
has priority over "mode": "full"
in tact.config.json
.
Co-authored-by: Anton Trunov <[email protected]>
Yup, will correct priorities |
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.
Great effort @vitorpy, @novusnota! Tact is much more interactive now
btw, added a few more things to work on in terms of enhancing Tact's CLI into the tracking issue #136 would be pretty cool to have the |
Nice! AST ones would drive their API counterparts, which is a big aid for tooling
Not sure about this, as there's already Nujan and (upcoming once I sort out my doc-related and Sublime/Emacs-related debts) interactive |
this is why it's for expressions only :) Tact has some unusual semantics for expressions: for instance, the integer division operation rounds towards negative infinity. That flag makes it easier to experiment when you do your stuff using your terminal. And with something like fzf you have easily searchable interaction history available, even if you do not have a nice REPL ready yet. |
Ok, I see the point now.
Well, on that note, we may just make a basic REPL for Tact expressions a part of the CLI — by using the readline module of Node: https://nodejs.org/api/readline.html As an idea, the actual expression for the |
A dedicated repl in addition to a cli option would be indeed nice! The option allows for better scriptability |
Closes #1516
Closes #1517
Closes #1518
Closes #1519
Uses meow to rewrite the CLI. Things I added in this PR:
--func
--check
bin/tact
file.Does this sounds reasonable?