Skip to content

Conversation

@benjamin-stacks
Copy link

Closes #6496.

That issue reported that clarity-eval SPWHATEVER something.clar hangs forever, but it turns out that that's only half true. What it's in fact doing is waiting for stdin input.

The Clarity program file name is an optional argument, and if it's not given, the program is read from the standard input instead. In the above example command line, something.clar is interpreted as the VM state DB directory instead (which is obviously not the caller's intention).

I made three changes:

  • The usage message now uses the common format where all optional args are wrapped in square brackets and required args are unwrapped:

    Usage: clarity-cli eval [--costs] [--epoch E] [--clarity_version N] contract-identifier [program.clar] vm-state.db

  • I also added the info to the help message that without the program.clar, things will be read from stdin.

  • And I changed the order of execution so that the contract ID and the VM DBs are handled first, before the program content is loaded. That way, if the user passes a something.clar but (incorrectly) leaves off one of the required args, it immediately causes an error, instead of waiting for the program from stdin and then erroring.

I also fixed the VSCode launch settings for clarity-cli.

@CLAassistant
Copy link

CLAassistant commented Dec 3, 2025

CLA assistant check
All committers have signed the CLA.

…fusing

Closes stacks-network#6496.

That issue reported that `clarity-eval SPWHATEVER something.clar`
hangs forever, but it turns out that that's only half true. What it's
in fact doing is waiting for `stdin` input.

The Clarity program file name is an optional argument, and if it's not
given, the program is read from the standard input instead. In the above
example command line, `something.clar` is interpreted as the VM state DB
directory instead (which is obviously not the caller's intention).

I made three changes:

- The usage message now uses the common format where all optional args
  are wrapped in square brackets and required args are unwrapped:

  ```
  Usage: clarity-cli eval [--costs] [--epoch E] [--clarity_version N] contract-identifier [program.clar] vm-state.db
  ```
- I also added the info to the help message that without the
  `program.clar`, things will be read from `stdin`.
- And I changed the order of execution so that the contract ID and the
  VM DBs are handled first, before the program content is loaded. That
  way, if the user passes a `something.clar` but (incorrectly) leaves
  off one of the required args, it immediately causes an error, instead
  of waiting for the program from `stdin` and *then* erroring.

I also fixed the VSCode launch settings for clarity-cli.
@benjamin-stacks benjamin-stacks force-pushed the fix/clarity-cli-eval-stdin branch from 8eb8bd8 to 4dd4ed0 Compare December 3, 2025 11:51
@benjamin-stacks
Copy link
Author

(I know history rewrites and force pushes are discouraged, but since the original branch brought some weird commits along and I had only just opened this PR, I assume that was still fine)

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.96%. Comparing base (67f1283) to head (4dd4ed0).

Files with missing lines Patch % Lines
contrib/clarity-cli/src/lib.rs 66.66% 3 Missing ⚠️

❌ Your project check has failed because the head coverage (75.96%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6738      +/-   ##
===========================================
+ Coverage    70.62%   75.96%   +5.34%     
===========================================
  Files          578      578              
  Lines       358784   358786       +2     
===========================================
+ Hits        253376   272537   +19161     
+ Misses      105408    86249   -19159     
Files with missing lines Coverage Δ
contrib/clarity-cli/src/lib.rs 76.28% <66.66%> (+2.24%) ⬆️

... and 262 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67f1283...4dd4ed0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@brice-stacks brice-stacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@simone-stacks
Copy link

Looks good to me too!

@benjamin-stacks benjamin-stacks added this pull request to the merge queue Dec 5, 2025
Merged via the queue into stacks-network:develop with commit cf8d685 Dec 5, 2025
616 of 622 checks passed
@benjamin-stacks benjamin-stacks deleted the fix/clarity-cli-eval-stdin branch December 5, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants