Skip to content

Navigation Menu

Sign in
Sign up

Ideas could be taken from Commandly #63

Unanswered
divyeshio asked this question in Ideas and suggestions
Discussion options

Just noticed OpenCLI and found that I had been working on similar solution during the same time frame as OpenCLI was created and has lot of similarities (was unware that something like this was in progress). Therefore, I would like to introduce to Commandly , I created it's schema after having worked with so many different cli tools having various different standards and ways to call a cli tool.

I think we could take ideas from it and introduce them in OpenCLI, since OpenCLI is from spectreconsole I think it would be widely adopted and have much more larger impact. (I love spectreconsole and I use it my projects. I would be happy to contribute to it in all possible ways)

Few things I think could be added in OpenCLI are:

  • IDs for options, arguments, etc.
  • isDefault property on commands.
  • IsRepeatable property on options.
  • Data type like string, boolean, number, etc.
  • Short flag, long flag aliases
  • Key value separator for options. Some tools require spaces, = , colon, etc
  • Position property for Arguments.
  • Dependencies of an argument, option on other options.
  • Validations for input data on an option or argument.
  • Default Values

You can find full JSON schema here - https://github.com/divyeshio/commandly/blob/main/public/specification/flat.json

I have also created UI to edit and generate commands visually, check it out here - https://commandly.divyeshio.in/tools/yt-dlp/edit?tab=json

Also, I have created a very basic MCP server, but have plans to introduce a MCP tool so that AI tools could search for cli tools and be able to generate cli commands accurately.

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

I'm not sure if tagging me is warranted. I've only contributed a small typo fix. But we do have something in common. I'm have also been build a cmd builder much like you Commandly. Although you seem to be ahead and mine is intended to be a TUI (not a GUI). I've been using this projects beta spec for my app and I have been keep some notes about the spec as I use it.

Let comment on you list:

  • IDs for options, arguments, etc. -- I have not found a need for this in my app yet. I'm curious what you would normally put for an id, like UUID?
  • isDefault property on commands. -- I'd like to know more about what you mean by this? I'm unclear on it.
  • IsRepeatable property on options. -- this one is interesting. I've generally assumed that options are repeatable but more explicit might be better here. The Argument Object has an arity field that might server this purpose if added to options
  • Data type like string, boolean, number, etc. -- This could be useful for error checking but it is bag of warms in that their are many different ways to specify data types and in the end all, terminal only except characters. I'd be interested if their is a useful line that we could draw that is not too permissive to be un-useful or too restrictive to make some commands indescribable.
  • Short flag, long flag aliases -- In my use, I've not found this restrictive, but my app only uses the canonical for which I expect to be in the name field and don't really use the aliases (it is opinionated in that way by design).
  • Key value separator for options. Some tools require spaces, = , colon, etc -- this is very much needed and in my notes. Although I've not run in to this issue yet it is only because I have not gotten to rendering the build command to a valid text string for a terminal. The Conventions Object object seem like a good place to this unless we think different option in the same command have different separators
  • Position property for Arguments. -- I'd like to hear more about this. I've been assuming that the postion in the array was it postion in the command. So like for mv you would specify first the an Argument Object that is the source file with an arity that is 1-* arguments and then an Argument Object that is the dest file with an arity that is 1. What usecases can the current spec describe?
  • Dependencies of an argument, option on other options. -- I'd image there be dragons here. What commands and use-case have you encountered that leads you to want this? I'll love to hear about it.
  • Validations for input data on an option or argument. -- I think this could be very useful but I might be inclined to feel that this is an unnecessary complication on a initial version of the spec. Maybe?
  • Default Values -- I want this too. The initial command that I'm building my app around is kubectl and they have the default value (the value taken if the option is not specified) in the usage documentation. I would like to be able to document this in the spec. I think it is important for those that are trying to build commands.

You have covered most of my notes except:

  • It would be useful to be able to specify that common use of -- which often detones the end of the parsing by the given command and everything after it is given to so other command. For example kubectl exec -it transform-nifi-0 -c metrics -n dev -- /bin/sh -c "cat /etc/hosts" I'm not totally sure what a good way to do this in the opencli spec but it is commonly used.
  • Some of the default values in the documentation are not reflected in the json schema. I was going to open a PR for that at some point, easy fix.

@divyeshio I hope this is not too long coming. Having uses even in this alpha or bata stage is very useful. I was not sure if anyone was using it when I adopted it but I did not find anything else I did not want to create my own.

@patriksvensson Please let me know if there are better places to discuss this.

You must be logged in to vote
1 reply
Comment options

Apologies for tagging, I just wanted some attention. And Thank you for taking time and replying. Here's my take on it:

  • Ids : Commandly supports, flat style json schema too, when two commands had same sub commands, ids were required to distinguish them and define relations. Another use case was to be able to dump everything into a database. This was specific to my needs.
  • isDefault : It serves as root command from OpenCLI, noticed root command already has arguments and options. This can be ignored.
  • IsRepeatable: Not necessarily, some options can only be used once, unless isRepeatable specified. Using arity might not be the right fit here.
  • Data types: There are only limited options available, and I feel like this should be part of schema, not just for validations, but to be able to represent it in GUI as well as useful for LLMs too.
  • Short flag: Depends on the use case. But would be great to be able to specify it.
  • Position property for Arguments - Depending on position in the array does not feel great, as the array could be shuffled, or get parsed in different order. Having a proper position field in spec solidifies it. I did not understand the second part here.
  • Dependencies of an argument, option on other options: Sometimes, tools require, certain options to be invoked along with certain other options. Or be invoked mutually exclusive, this is to represent that nature.

Regarding usage of --, I haven't explored it yet. But I think we could treat -- as an option key and rest of it as a value

Forgot to mention earlier, and in case it wasn't obvious my use case also involves LLMs to be able to generate commands with latest options and to be able to generate spec even with just help text (many of the things specified above are useful for LLMs). Commandly has a feature where you can just paste the help text and it will generate full json schema representation for you.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /