percyqaz / Percyqaz.Shell

Toolkit to add command line/IPC capabilities to your F# application
MIT License
1 stars 0 forks source link

Multi-word command syntax #6

Closed percyqaz closed 1 year ago

percyqaz commented 1 year ago

I want multi word commands command sub

But I also want quoteless string arguments command arg

How can I make these two things unambiguous

The real answer is to use brackets: command(arg) and command sub(arg) But I want to maintain the shell style

also maybe modules should be capitalised and commands be lower case Then Module.object.prop arg is acceptable syntax

What about some awful hack like an object can be executed as a command if it defines _c as a property

Then multi word commands are command.sub arg with command arg still executable

percyqaz commented 1 year ago

Proposed changes:

command arg1 arg2 interprets everything literally as space separated strings command $var arg2 interprets 1st argument as the variable var In general command $(expression in brackets here) $(expression in brackets here) evaluates those expressions and inserts those as the arguments You cannot mash up nonsense like command arg_$(stuff) and to enter a real $ use command $$expr or command "$expr"

Still need to fix ambiguity var calling var with 0 arguments, getting return value var referring to var itself, can be passed into other functions I think maybe @var can refer to the command itself if var is a command var can refer to either a value or executing the command

Ends up being quite a few changes including adding type coercing and stuff but I think nice overall

percyqaz commented 1 year ago

Bing done except the cmd vs @cmd business since applications need to evaluate just cmd on its own (which would try to call it with 0 arguments)

percyqaz commented 1 year ago

Suck it up for now you will just have to call your 0 arity commands manually