Code Monkey home page Code Monkey logo

cargo-rx's People

Contributors

cb-rnag avatar rnag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cargo-rx's Issues

fix color output for powershell in windows

  • cargo-rx version: 0.1
  • Rust Compiler (rustc) version: ?
  • Operating System: windows 11 64-bit

Description

In powershell i see weird characters being shown instead of normal color output, for ex. when script outputs the >> cargo run --example <name> before running the script, for example.

I need to research why it's happening and how to resolve it. I think it's the way we're invoking shell command in code, the pipe command which basically performs the equivalent of echo 'one\ntwo\nthree' | fzf apparently is not supported well in windows / powershell, at least from what I could tell when searching online.

We need a way to not break colored text output in powershell when piping output of echo to another process like fzf.

What I Did

$ rx

I need help to strip out the start of screen demo

Description

demo link:
https://asciinema.org/a/483363

This might be a bit of a stupid thing, but I need help to strip out the first few seconds (~5 seconds or so) from the start, where it shows as session restored. I tried with asciinema-edit but couldn't get it to work on my side (using mac). In case curious, I open an issue in the linked project.

For now my setting on asciinema.org are to set idle_time_limit=1.0 but that's not ideal as it speeds up commands in general. so I just want to know how can i strip out first few seconds from the start (and maybe last second or too too). thx ~

What I Did

trying with asciinema-edit (anyone else have this problem btw?)

$ cat ~/Downloads/483363.cast | asciinema-edit cut  --start=0.0 --end=5.0 
failed to transform cast: couldn't find initial frame

feature request: better preview output with `skim`

  • cargo-rx version: 0.1
  • Rust Compiler (rustc) version: 1.59
  • Operating System: Mac OS X

Description

The current output in preview window displayed with skim is nice and works currently for our purposes, but a future idea might be to customize what gets displayed in preview pane on the right side.

For example, do still want to continue displaying the source code of the example file -- might it make sense to instead display the doc comments, or just any regular comments in the example, for instance? also in that case, would we want to automatically strip out the //! and leading spaces, and format the comments nicely?

Side note: I've noticed that in some projects there are comments or info on a specific example that is encapsulated as part of a separate file, generally a text/markdown file. For example, for an example like my_example.rs, in the same directory there is often a separate my_example.md file which documents info about the example. Maybe, in such cases it would be nice to populate the preview pane with the contents of this markdown file, rather than the source file contents.

Future, future idea: maybe we implement a terminal-based parser for Markdown? I think it would be cool to see **text** be translated as bold text in the terminal, and ## Header as a slightly bigger font size or maybe text with a custom background, for example.

Work with crates?

Is your feature request related to a problem? Please describe.

Some libraries like tract and axum use workspaces to indicate examples, but current cargo-rx does not seem to able to identify them.

Describe the solution you'd like

Identify workspaces for examples based on directory names?

Additional context

No.

format and stylize block comments as expected

Description

See #11 for sample terminal output.

Essentially, we need to figure out a way to support identifying block comments within /*! <snip> !*/ (for doc comments) or within /* <snip> */ for regular comments, so that we can format and stylize such comments (colored text, bolding, etc.) as expected.

What I Did

I just went into my project folder and ran:

$ rx

pre-select the last run example for a crate

It would be nice to pre-select the last-run example on a per crate basis, whenever rx is invoked without arguments.

For instance, if the last run example was my_example and the arguments passed to the example were --my-arg test, then in the selection list that gets displayed when rx is run without arguments, it would be nice to pre-select my_example from the list of available examples for the crate; and the same arguments from last time should be passed in to the example when a user confirms the selection with the Enter key.

list of examples is not sorted

  • cargo-rx version: 0.1.0
  • Rust Compiler (rustc) version: 1.59
  • Operating System: Mac OS X

Description

Output with list of examples is not sorted alphabetically (or even reverse sorted Z->A would be nice), but ideally I suppose it should be.

example for my project smartsheet-rs:

image

What I Did

I just cd into my project folder after a git clone and run:

$ rx

feature: set up tab completion for positional arguments

Description

It would be nice to set up tab completion for the first positional argument after rx, similar to how it auto completes when you type cd to switch into a directory and press tab after entering a partial match, for example.

The rx command in this case should offer auto-completion suggestions based on the list of examples for the current Cargo project.

For example if there is a single example in a project called hello_world.rs, when I enter hello it should auto complete to hello_world. If there is more than one example that starts with the entered term, it should offer all possible examples that match the query.

prompt for argument automatically, *If* we determine an example requires arguments

  • cargo-rx version: 0.1
  • Rust Compiler (rustc) version: 1.59
  • Operating System: Mac OS X

Description

I want rx to automatically prompt for arguments -- i.e. same as invoking --parse-args -- when we can determine that an example script requires arguments passed in from command-line.

Some ideas on what might work:

  • Scan example file for a markdown header in doc comments, like //! # Arguments
  • Look for a specific keyword in either doc comments or just regular comments. For instance, the keyword might be like rx:requires_args. This way our script knows for certain that a script requires command-line arguments, and can prompt user to input arguments automatically.

Add a "Did you mean?" prompt if user misspells example name, and optionally re-run if the user says "Yes!"

Is your feature request related to a problem? Please describe.

I don't know if it's possible but I'd like to suggest auto-correction if a user misspells or mistypes an example name, similar to how cargo run --example does it already currently.

Related Issues

#18

Describe the solution you'd like

Potentially something like:


Sorry bud, no such example `my_exmaple` exists.

Did you mean `my_example`? [Y/N]:  $  
Did you mean `my_example`? [Y/N]:  $  y

[Runs the example file `my_example`...]

Describe alternatives you've considered

I haven't actually looked into any existing solutions for spelling correction yet. It would be cool to implement this, I feel. Preferably with the least overhead in terms of overall dependency size, compilation or build time, etc.

Additional context

It's not too necessary as when we call cargo run --example, it'll already offer an auto correction hint. But I think it's nice to add proactive spellchecking and correction -- this way it'll be a little faster, as we can catch the error earlier, and we don't need to waste time spawning a new process to call cargo run --example when we already know the example name is misspelled, for example.

Just for completeness sake, Here's a sample auto correction hint from cargo run --example on one of my projects, which I think is really cool/nice:

PS serde-this-or-that> cargo run --example d
error: no example target named `d`

        Did you mean `demo`?

Add extra options that `cargo run` supports

Is your feature request related to a problem? Please describe.

I would like to be able to pass options such as --features or --release -- which cargo run supports currently -- to the rx command.

Describe the solution you'd like

I would like to update rx to also accept same options that cargo run --example does.

Additional context

I need to pass --features in another project currently for some examples occasionally, so this would be helpful to enable. My use case is I have a separate feature for dev/prod environments; and occasionally I would like to run an example for a production environment, i.e. with the relevant feature enabled.

text wrap comments to completely fit within the preview pane

  • cargo-rx version:
  • Rust Compiler (rustc) version:
  • Operating System:

Description

Instead of displaying the example file contents directly in the preview pane, it'd be ideal to leverage a text wrapping library such as textwrap to wrap the doc comments -- and regular comments if feasible -- so that we can be sure that the comments completely fit within the preview pane, and are displayed as expected without any text cutting off near the end.

For example, note that comments in a line that are past a max width are hidden in the preview pane currently:
image

Related Issues

This issue goes with #12

What I Did

I just cd into my project folder and ran:

$ rx

examples nested in sub-folders should be included

Description

This is a simple fix, but basically nested examples like examples/some_example/main.rs are not captured currently, since we only look one level deep, specifically for rust (.rs) source files.

Here we will need to update our code to traverse directories in examples/ folder (at least one level deep for now, not sure if Cargo itself supports examples deeply nested in sub-folders) and search for any main.rs files. The example name displayed should of course be the subfolder name in this case.

What does this involve exactly?

Support following paths for rust files in the examples/ folder:

  • Files with custom paths not picked up by cargo by default, for instance example/my_folder/my_example_here.rs
    • In order to achieve this, we need to scan through the list of [[example]] sections in the Cargo.toml file
  • Multi-file examples with a main.rs file that cargo supports, such as examples/my_folder/main.rs

calculate width of left pane based on the max length of example filenames

  • cargo-rx version: 0.1
  • Rust Compiler (rustc) version: 1.59
  • Operating System: Mac OS X

Description

It would be ideal to calculate the current console width, then calculate the max width of the stem of each example file (filename without the extension). The max stem width can then be used to set the width of the left pane, and the remaining console width can be taken up by the preview pane on the right.

For example (note the three dots ... below):

Screen Shot 2022-04-04 at 11 15 11 AM

What I Did

Within my project folder, I just ran:

$ rx

Automatically replace dashes `-` with underscores `_` in example names, if necessary

Is your feature request related to a problem? Please describe.

It would be cool if we can automatically replace dashes - with underscores _ (or vice versa) if we determine that a user-entered example name with dashes - is not a valid example, but that it would be instead valid with _.

The main impetus for this is that it is somewhat easier to type a dash - on a keyboard - don't need to make a beeline for the shift key, for example. ๐Ÿค”

Describe the solution you'd like

Current output when running cargo run --example, when mis-typing _ as - for instance:

PS serde-this-or-that> cargo run --example as-string
error: no example target named `as-string`

        Did you mean `as_string`?

Desired output:

PS serde-this-or-that> rx as-string

>> cargo run --example as_string
[result of running the `as_string` example]

add quotes around multi-word arguments, when displaying equivalent `cargo run --example` command

Version

0.1.0

Platform

Mac OS X

Description

When running rx against an example that takes arguments, when I add quotes around an argument, I would expect the terminal output which displays the command to similarly include quotes around my argument.

For example, when I run following command and select an example my_example:

$rx -- --my-arg 'my "name" here'

the terminal output of the command being run is currently like:

>> cargo run --example my_example -- --my-arg my name here

when instead, I want it to display like:

>> cargo run --example my_example -- --my-arg "my \"name\" here"

...which more closely matches the format of the command being run. it's also helpful so that we can use the command being printed out for debugging purposes, and if we just copy-paste the command into a terminal window verbatim, it should work the same to run cargo run --example and not cause any errors when running the example using that approach.

Traverse workspace members (each with their own binaries and examples)

Is your feature request related to a problem? Please describe.

Let's use this project as an example:
https://github.com/sonos/tract

Support Binaries in src/bin

I try to run cargo run at root level, I get following output:

$ cargo run
error: `cargo run` could not determine which binary to run. Use the `--bin` option to specify a binary, or the `default-run` manifest key.
available binaries: example-dump-nnef-mobilenet-v2, example-nnef-mobilenet-v2, example-onnx-mobilenet-v2, example-pytorch-resnet, example-tensorflow-mobilenet-v2, jupyter-keras-tract-tf1, jupyter-keras-tract-tf2, pytorch-albert-v2, reset-test-list, tract

Hmm - that's strange! Where did all those binaries come from? It's really interesting, because those are not ones defined at root level either. Looks like those are binaries/examples of workspace members actually.

Take this binary target: reset-test-list

It looks like that is actually coming from a workspace member, harness/onnx-test-suite > src > bin > reset-test-list.rs. So we need to support this use case first of all - binaries in src/bin of a workspace member.

Support examples (in workspace members)

Now, when I run cargo run --example:

$ cargo run --example
error: "--example" takes one argument.
Available examples:
    plus3

Hmm - that's really interesting! There is no such example at root level, under example > plus3.rs. What gives? It looks like this is actually an example from a workspace member, tensorflow > examples > plus3.rs. So we will also need to support such examples within workspace members as well.

Describe the solution you'd like

All runnable targets are included in output when rx is entered in a terminal.

Describe alternatives you've considered

n/a

Additional context

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.