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

Create a tool to extract a bash script from a Linera README file #3114

Merged
merged 5 commits into from
Jan 11, 2025

Conversation

ma2bd
Copy link
Contributor

@ma2bd ma2bd commented Jan 10, 2025

Motivation

This was suggested by the community and team members also hacked a local solution at times.

fixes #1456

Proposal

  • Some light refactoring
  • Add a command linera extract-script-from-markdown. The command is hidden because we may arbitrarily change or remove it in the future.

Test Plan

CI

cargo build
target/debug/linera extract-script-from-markdown examples/fungible/README.md | bash

Release Plan

  • Nothing to do / These changes follow the usual release cycle.


pub fn path(&self) -> &Path {
&self.path
impl Markdown<std::io::BufReader<fs_err::File>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

(Nit: I'd use std::io and remove all those std::.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I like use std::io so much. I added a few others instead.

) -> std::io::Result<Vec<String>> {
let mut result = Vec::new();
let mut lines = reader.lines();
) -> Result<(), std::io::Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
) -> Result<(), std::io::Error> {
) -> io::Result<()> {

output,
"JSON_QUERY=$(jq -n --arg q \"$QUERY\" '{{\"query\": $q}}')"
)?;
writeln!(output, "QUERY_RESULT=$(curl -w '\\n' -g -X POST -H \"Content-Type: application/json\" -d \"$JSON_QUERY\" {uri} \
Copy link
Contributor

Choose a reason for hiding this comment

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

(Line too long.)

@ma2bd ma2bd merged commit 9d88a5e into linera-io:main Jan 11, 2025
22 checks passed
@ma2bd ma2bd deleted the readme_tool branch January 11, 2025 16:58
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.

Add a tool to extract bash commands from README files
2 participants