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
[Cli 2.0]: Pipe conan commands POC #7696
Conversation
Co-authored-by: Javier G. Sogo <jgsogo@gmail.com>
nargs="?") | ||
parser.add_argument("-r", "--remote", action=OnceArgument, | ||
help="Upload to this specific remote") | ||
parser.add_argument("--query", default=None, action=OnceArgument, |
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.
This would be a perfect candidate to get out of here, and pipe the result of conan search --query
into conan upload
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.
I am not convinced about this approach. It is basically one abstraction pipeable
instead of directly defining a pipe
argument to argparse, that in any case needs to be parsed by each command, there is no automatic mapping to the corresponding argument.
Besides that small architecture detail, I don't feel this provides the most UX friendly flow. While it seems correct conceptually and it matches the linux command line, that is for "simple" commands piping, like ls, cat, grep
, and similar low level system utilities. But conan create
does a ton of things, and conan upload
does another tons of thing. I feel that both in CI and user usage, it might be better to do one thing at a time, and then use file outputs or other mechanism to let the information flow. Plus having an intermediate file that can be provided to conan upload
for example, would enable further automation by users, that could create that file themselves.
I think we want to delay this decision for later, and mature first the real cases we want to implement, like create + upload (what if create has --build=missing and build more things? should return something more than the reference being created?), and if there is a common pattern, we will factor it. What do you think @czoido ?
Yes, I agree. Maybe we want something more powerful than just piping commands. For me, as I saw this, piping between commands would only work for some commands and some cases but and maybe it's not really solving any problem or improving flows. Maybe it would, but I think it's a good idea to study the real world cases we want to improve deeper and then see how different approaches work would be the best. |
Here are some thoughts surrounding the work and discussion done so far. TLDR; the suggestion is to resume work on adding pipe support for Conan 2.0, with some more clear parameters and goals, and more feedback from users.
Here's an example of my own actual suggestion from 2019:
I believe there are many more opportunities for new and useful bridge commands like this. |
Conan 2.0 new CLI is almost there, and so far we haven't found solid and clear cases of Conan command piping, so it seems this might not be necessary atm. |
This PR is a proof of concept about the idea of being able to pipe conan commands. It has minimal implementations of the commands
create
andupload
to demonstrate how after the creation of a package the upload process can take advantage of the results instdout
of thecreate
command.Do export the environment variable:
export CONAN_V2_CLI=1
before trying.Possible uses:
$ conan create path/conanfile.py --user=carlos --channel=experimental | conan upload pkg/1.0@carlos/experimental#cfeb566fb51ca21a2f549c969c907b53:587de5488b43bc9cebd0703c6c0f8c74#cfeb566fb51ca21a2f549c969c907b53
You can also take the json output and use something like jq to parse the json output from a previous conan command:
The piping capability is added in the
conan_command
orconan_subcommand
decorators. This can be discussed if the user must have total control over this, maybe we want to take it outside there and define in the commands.The positional argument it can substitute then has to be marked as optional so that Argparse accepts the input argument when passed explicitly or the piped stdin when detected a piped command.