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

cross --list lists commands that will not run #715

Closed
abentley opened this issue May 24, 2022 · 1 comment · Fixed by #719
Closed

cross --list lists commands that will not run #715

abentley opened this issue May 24, 2022 · 1 comment · Fixed by #719

Comments

@abentley
Copy link

$ cross --list|grep -C1 deb
    d                    alias: doc
    deb
    doc                  Build a package's documentation
$ cross deb
error: no such subcommand: `deb`

	Did you mean `b`?

"deb" here is cargo-deb. It would be nice if it could be used to generate deb packages for old distros, but since it can't, it shouldn't be listed.

@Alexhuszagh
Copy link
Contributor

There seems to be 2 issues here, I believe.

This seems to be an issue with deb being recognized as a sucommand explicitly, but cargo-deb is not actually installed for the image's cargo. Normally, for a list of recognized subcommands, we run them in the image, otherwise, we fall back to cargo on the host. However, this doesn't work since we don't necessarily have the correct toolchain on the host.

Related Issues/PRS:
#130
#210

The other issue is that cross --list actually falls back to the host cargo, so it lists every subcommand on the host, which I don't believe is desirable. We should probably add --list to the known subcommands.

An extra feature worth considering is due to custom images, it might be worth writing a config file with extra subcommands that are written at the end of the build step, so that these subcommands are run using cross and the rest fall back to cargo. We could also just parse the output of cargo --list in the image and determine if the subcommand is installed on the image's cargo. This would be especially relevant if pre-build hooks (#635) or similar are ever added.

Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 25, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as
pseudo-subcommands.

Fixes cross-rs#715.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 25, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as
pseudo-subcommands.

Fixes cross-rs#715.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 27, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

This works by capturing the output subcommand list, and then classifying them
as either subcommands from the host or container. This also future proofs
our logic, if we ever get support for custom subcommands, since only `Other`
(unrecognized) subcommands are treated as host commands.

Sample Output:
```
Cross Commands:
    b                    alias: build
    bench                Execute all benchmarks of a local package
Host Commands:
    afl
    asm
    clean                Remove artifacts that cargo has generated in the past
```

Fixes cross-rs#715.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 27, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

This works by capturing the output subcommand list, and then classifying them
as either subcommands from the host or container. This also future proofs
our logic, if we ever get support for custom subcommands, since only `Other`
(unrecognized) subcommands are treated as host commands.

Sample Output:
```
Cross Commands:
    b                    alias: build
    bench                Execute all benchmarks of a local package
Host Commands:
    afl
    asm
    clean                Remove artifacts that cargo has generated in the past
```

Fixes cross-rs#715.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 27, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

This works by capturing the output subcommand list, and then classifying them
as either subcommands from the host or container. This also future proofs
our logic, if we ever get support for custom subcommands, since only `Other`
(unrecognized) subcommands are treated as host commands.

Sample Output:
```
Cross Commands:
    b                    alias: build
    bench                Execute all benchmarks of a local package
Host Commands:
    afl
    asm
    clean                Remove artifacts that cargo has generated in the past
```

Fixes cross-rs#715.
Alexhuszagh added a commit to Alexhuszagh/cross that referenced this issue May 28, 2022
`cross --list` should list the subcommands present for cargo in the
image, rather on the host. This works because any option provided before
a subcommand has priority over the subcommand. For example, `cargo build
--help` prints the help menu for `cargo build`, but `cargo --help build`
ignores `build` and prints the help for `cargo`. Therefore, the options
`--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

This works by capturing the output subcommand list, and then classifying them
as either subcommands from the host or container. This also future proofs
our logic, if we ever get support for custom subcommands, since only `Other`
(unrecognized) subcommands are treated as host commands.

Sample Output:
```
Cross Commands:
    b                    alias: build
    bench                Execute all benchmarks of a local package
Host Commands:
    afl
    asm
    clean                Remove artifacts that cargo has generated in the past
```

Co-authored-by: Emil Gardström <emil.gardstrom@gmail.com>

Fixes cross-rs#715.
bors bot added a commit that referenced this issue May 28, 2022
719: Add --list to known subcommands. r=Alexhuszagh a=Alexhuszagh

`cross --list` should list the subcommands present for cargo in the image, rather on the host. This works because any option provided before a subcommand has priority over the subcommand. For example, `cargo build --help` prints the help menu for `cargo build`, but `cargo --help build` ignores `build` and prints the help for `cargo`. Therefore, the options `--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

Fixes #715.

Co-authored-by: Alex Huszagh <ahuszagh@gmail.com>
bors bot added a commit that referenced this issue May 28, 2022
719: Add --list to known subcommands. r=Alexhuszagh a=Alexhuszagh

`cross --list` should list the subcommands present for cargo in the image, rather on the host. This works because any option provided before a subcommand has priority over the subcommand. For example, `cargo build --help` prints the help menu for `cargo build`, but `cargo --help build` ignores `build` and prints the help for `cargo`. Therefore, the options `--help`, `--version`, and `--list` can be treated as pseudo-subcommands.

Fixes #715.

Co-authored-by: Alex Huszagh <ahuszagh@gmail.com>
@bors bors bot closed this as completed in 0938182 May 28, 2022
@bors bors bot closed this as completed in #719 May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants