Re: [racket-users] Re: A language for command line interfaces

2021-07-25 Thread Siddhartha Kasivajhula
Good call, I'll add a note to the effect. Btw in case it wasn't clear from
my response, using #lang cli shouldn't affect the existing workflows that
you mentioned, although, you would probably want to define the command line
component of your code as a separate #lang cli module, rather than in a
module+ main.


On Sun, Jul 25, 2021 at 12:21 PM D. Ben Knoble  wrote:

> > Right, thank you for bringing that up. I should have mentioned that the
> #lang provides all of racket/base at the module level, so you can write
> normal Racket code (including `require`), and any imports at the module
> level would be available within the `program` body since it compiles down
> to a normal function.
> >
> > You can also use `provide`, so once you define your command using
> `program`, you can provide it the same as any function. The client module
> requiring your command would need to be a #lang cli module (at least at the
> moment) so that it can actually run the imported command using `run`.
>
> That would be good to add to the docs in my opinion.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CACQBWFmbq1bPs4-66mkxCVVC9Ob6EJ7ovw-3%3D%2B%3DuBd2ZexGBcA%40mail.gmail.com.


Re: [racket-users] Re: A language for command line interfaces

2021-07-25 Thread D. Ben Knoble
> Right, thank you for bringing that up. I should have mentioned that the #lang 
> provides all of racket/base at the module level, so you can write normal 
> Racket code (including `require`), and any imports at the module level would 
> be available within the `program` body since it compiles down to a normal 
> function.
>
> You can also use `provide`, so once you define your command using `program`, 
> you can provide it the same as any function. The client module requiring your 
> command would need to be a #lang cli module (at least at the moment) so that 
> it can actually run the imported command using `run`.

That would be good to add to the docs in my opinion.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CALnO6CAsxaJ%3DHsPJE1ZnOJXs9yVobiRiSBOj9UV4cxC%2BLRqiiw%40mail.gmail.com.


Re: [racket-users] Re: A language for command line interfaces

2021-07-25 Thread Siddhartha Kasivajhula
Right, thank you for bringing that up. I should have mentioned that the
#lang provides all of racket/base at the module level, so you can write
normal Racket code (including `require`), and any imports at the module
level would be available within the `program` body since it compiles down
to a normal function.

You can also use `provide`, so once you define your command using
`program`, you can provide it the same as any function. The client module
requiring your command would need to be a #lang cli module (at least at the
moment) so that it can actually run the imported command using `run`.


On Sun, Jul 25, 2021 at 11:23 AM D. Ben Knoble  wrote:

>
> The language is composed of 5 forms - help, flag, constraint, program,
>> and run. With these 5 forms, you get all of the functionality of the
>> built-in parse-command-line form, and with syntax that's much simpler.
>> In fact, the nontrivial forms of the language simply use Racket's normal
>> function definition syntax, so there's very little to learn -- you
>> basically write normal functions and they are implicitly wired to accept
>> their inputs via the command line.
>>
>
> Could we add require? I can think of two compelling reasons:
>
> 1. What else is available in the program form? All of racket, or just
> racket/base? And either way, what if I want to use procedures from other
> packages?
> 2. What if I want to write a bunch of library code, and expose some of it
> in a CLI script? I do this now in different ways: a module+ main that uses
> code defined in the enclosing module, or a script that requires auxiliary
> modules. Often the "body" of the program form isn't more than a call to a
> "main" procedure: this enables me to provide that procedure as part of the
> library, too.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/a0a0ffba-b8a5-4b57-8fc1-b24a821de85cn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CACQBWF%3DQS%3DKu%3DZ-NfSLqmeOq8fb6FOcnA0GkL1xh-kT8WXw0-A%40mail.gmail.com.


[racket-users] Re: A language for command line interfaces

2021-07-25 Thread D. Ben Knoble


> The language is composed of 5 forms - help, flag, constraint, program, 
> and run. With these 5 forms, you get all of the functionality of the 
> built-in parse-command-line form, and with syntax that's much simpler. In 
> fact, the nontrivial forms of the language simply use Racket's normal 
> function definition syntax, so there's very little to learn -- you 
> basically write normal functions and they are implicitly wired to accept 
> their inputs via the command line.
>

Could we add require? I can think of two compelling reasons:

1. What else is available in the program form? All of racket, or just 
racket/base? And either way, what if I want to use procedures from other 
packages?
2. What if I want to write a bunch of library code, and expose some of it 
in a CLI script? I do this now in different ways: a module+ main that uses 
code defined in the enclosing module, or a script that requires auxiliary 
modules. Often the "body" of the program form isn't more than a call to a 
"main" procedure: this enables me to provide that procedure as part of the 
library, too.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a0a0ffba-b8a5-4b57-8fc1-b24a821de85cn%40googlegroups.com.