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

2021-07-24 Thread Siddhartha Kasivajhula
That's great to hear, Sage. My initial thrust here was to just get the
syntax in place so that it worked the way it should, and I didn't give a
lot of attention to the supporting implementation beyond that it should
work correctly. I definitely see a possibility for big changes there and
maybe even an intermediary layer between cli and racket/cmdline which could
be natural-cli or something resembling it. I made some notes regarding the
existing implementation and possible next steps in this issue
. Happy to discuss further
and I appreciate your offer to collaborate.

On Sat, Jul 24, 2021 at 10:47 AM Sage Gerard  wrote:

> Thank you for doing this. CLIs are an interesting beast, and I should be
> available to contribute and/or comment next week.
>
>
> *~slg*
>
>
>
>
>
>
>  Original Message 
> On Jul 24, 2021, 1:14 PM, Siddhartha Kasivajhula < skasi...@gmail.com>
> wrote:
>
>
> Hello folks,
> If you ever have a need to write a command line script in Racket, you may
> be interested in the package I've just put up. Normally you'd write such
> scripts using Racket's built-in command-line
> 
>  or
> parse-command-line
> 
>  form.
> These offer a lot of functionality, but it takes time to learn how they
> work and the syntax is somewhat idiosyncratic. So, I've written a #lang
> that allows you to achieve the same functionality but with more familiar
> and extensible syntax, #lang cli
> .
>
> 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.
>
> At the moment, the functionality offered is at parity with the built-in
> forms, but there are some planned additions that would make it more
> powerful, including composable commands
> , generalized constraints
> , and argument schemas
> .
>
> So if you write command line scripts, I encourage you to give it a try.
>
> I also coincidentally came across the package natural-cli
>  by Sage Gerard.
> Looks like it provides some interesting features and in particular
> subcommands, which are absent in #lang cli. It very well may be that this
> package should be leveraged for semantics in #lang cli in the future (Sage
> if you'd like to add anything about what this package offers, please do).
>
> Enjoy,
> -Sid
>
> --
> 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/CACQBWFnevJaRg61xLv6ayps-ihGpuUFUFEVbLTH7m929tpex3Q%40mail.gmail.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%3D9bQpNpc2ShAcARtuz0y7%3DvHuiyiU17eafx5DZ%3D6DKzA%40mail.gmail.com.


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

2021-07-24 Thread Sage Gerard
Thank you for doing this. CLIs are an interesting beast, and I should be 
available to contribute and/or comment next week.

~slg

 Original Message 
On Jul 24, 2021, 1:14 PM, Siddhartha Kasivajhula wrote:

> Hello folks,
> If you ever have a need to write a command line script in Racket, you may be 
> interested in the package I've just put up. Normally you'd write such scripts 
> using Racket's built-in 
> [command-line](https://docs.racket-lang.org/reference/Command-Line_Parsing.html#%28form._%28%28lib._racket%2Fcmdline..rkt%29._command-line%29%29)
>  or 
> [parse-command-line](https://docs.racket-lang.org/reference/Command-Line_Parsing.html#%28def._%28%28lib._racket%2Fcmdline..rkt%29._parse-command-line%29%29)
>  form. These offer a lot of functionality, but it takes time to learn how 
> they work and the syntax is somewhat idiosyncratic. So, I've written a #lang 
> that allows you to achieve the same functionality but with more familiar and 
> extensible syntax, [#lang cli](https://docs.racket-lang.org/cli/index.html).
>
> 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.
>
> At the moment, the functionality offered is at parity with the built-in 
> forms, but there are some planned additions that would make it more powerful, 
> including [composable 
> commands](https://github.com/countvajhula/cli/issues/3), [generalized 
> constraints](https://github.com/countvajhula/cli/issues/6), and [argument 
> schemas](https://github.com/countvajhula/cli/issues/7).
>
> So if you write command line scripts, I encourage you to give it a try.
>
> I also coincidentally came across the package 
> [natural-cli](https://docs.racket-lang.org/natural-cli/index.html) by Sage 
> Gerard. Looks like it provides some interesting features and in particular 
> subcommands, which are absent in #lang cli. It very well may be that this 
> package should be leveraged for semantics in #lang cli in the future (Sage if 
> you'd like to add anything about what this package offers, please do).
> Enjoy,
> -Sid
>
> --
> 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/CACQBWFnevJaRg61xLv6ayps-ihGpuUFUFEVbLTH7m929tpex3Q%40mail.gmail.com](https://groups.google.com/d/msgid/racket-users/CACQBWFnevJaRg61xLv6ayps-ihGpuUFUFEVbLTH7m929tpex3Q%40mail.gmail.com?utm_medium=email_source=footer).

-- 
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/rxdVJcMmBhW1Xtw4KZEtdl0qySeqWsbpKhW5wewaDeXGOm8PyjMWV4Q_fKXCzIitRyxDtZjRx4DtjMTi398FwMM1V3Y4lLX91urE3_N2zlE%3D%40sagegerard.com.


[racket-users] A language for command line interfaces

2021-07-24 Thread Siddhartha Kasivajhula
Hello folks,
If you ever have a need to write a command line script in Racket, you may
be interested in the package I've just put up. Normally you'd write such
scripts using Racket's built-in command-line

or
parse-command-line

form.
These offer a lot of functionality, but it takes time to learn how they
work and the syntax is somewhat idiosyncratic. So, I've written a #lang
that allows you to achieve the same functionality but with more familiar
and extensible syntax, #lang cli
.

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.

At the moment, the functionality offered is at parity with the built-in
forms, but there are some planned additions that would make it more
powerful, including composable commands
, generalized constraints
, and argument schemas
.

So if you write command line scripts, I encourage you to give it a try.

I also coincidentally came across the package natural-cli
 by Sage Gerard. Looks
like it provides some interesting features and in particular subcommands,
which are absent in #lang cli. It very well may be that this package should
be leveraged for semantics in #lang cli in the future (Sage if you'd like
to add anything about what this package offers, please do).

Enjoy,
-Sid

-- 
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/CACQBWFnevJaRg61xLv6ayps-ihGpuUFUFEVbLTH7m929tpex3Q%40mail.gmail.com.


[racket-users] Re: get-scaled-client-size and high-DPI on Windows

2021-07-24 Thread Ryan Kramer
Wow, how did I write that much and not notice `get-client-size`, which is 
exactly what I want? The documentation is fine, apparently I just can't 
read today!

On Saturday, July 24, 2021 at 10:55:58 AM UTC-5 Ryan Kramer wrote:

> The following program looks "correct" when my Windows display scaling is 
> set to 100%, and looks "wrong" when set to anything higher than 100%. By 
> "correct" I mean that the 4 squares meet in the center of the canvas, 
> stretched to the maximum size possible that the canvas width and height 
> will allow.
>
> What is interesting is that I can make the program look correct by 
> immediately scaling the values returned from `get-scaled-client-size`. For 
> example, if my display is set to 150%, I can make the program look correct 
> by immediately multiplying the returned width and height by 2/3, because 
> 100% is 2/3 of 150%. But right now I have to hard-code the 2/3 factor. Is 
> there a way to get that 2/3 factor programmatically in Racket? Or (even 
> better), is there something else I should be calling instead of 
> `get-scaled-client-size` that would return the dimensions I want?
>
> This is Racket CS 8.0.0.11 on Windows. Let me know if you want 
> screenshots. Thanks in advance.
>
>
> #lang racket/gui
>
> (require pict)
>
> (define frame
>   (new frame%
>[label "Scale Test"]))
>
> (define (paint canvas dc)
>   (define-values (w h) (send canvas get-scaled-client-size))
>   (define-values (size x-offset y-offset)
> (if (> w h)
> (values h (/ (- w h) 2) 0)
> (values w 0 (/ (- h w) 2
>   (println (list w h size x-offset y-offset))
>   (for ([x (list x-offset (+ x-offset (/ size 2)))]
> #:when #t
> [y (list y-offset (+ y-offset (/ size 2)))])
> (send dc draw-rectangle x y (/ size 2) (/ size 2
>
> (define canvas
>   (new canvas%
>[parent frame]
>[paint-callback paint]))
>
> (send frame show #t)
>
>

-- 
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/31a9adf4-c257-4871-88a5-6a01e9857f43n%40googlegroups.com.


[racket-users] get-scaled-client-size and high-DPI on Windows

2021-07-24 Thread Ryan Kramer
The following program looks "correct" when my Windows display scaling is 
set to 100%, and looks "wrong" when set to anything higher than 100%. By 
"correct" I mean that the 4 squares meet in the center of the canvas, 
stretched to the maximum size possible that the canvas width and height 
will allow.

What is interesting is that I can make the program look correct by 
immediately scaling the values returned from `get-scaled-client-size`. For 
example, if my display is set to 150%, I can make the program look correct 
by immediately multiplying the returned width and height by 2/3, because 
100% is 2/3 of 150%. But right now I have to hard-code the 2/3 factor. Is 
there a way to get that 2/3 factor programmatically in Racket? Or (even 
better), is there something else I should be calling instead of 
`get-scaled-client-size` that would return the dimensions I want?

This is Racket CS 8.0.0.11 on Windows. Let me know if you want screenshots. 
Thanks in advance.


#lang racket/gui

(require pict)

(define frame
  (new frame%
   [label "Scale Test"]))

(define (paint canvas dc)
  (define-values (w h) (send canvas get-scaled-client-size))
  (define-values (size x-offset y-offset)
(if (> w h)
(values h (/ (- w h) 2) 0)
(values w 0 (/ (- h w) 2
  (println (list w h size x-offset y-offset))
  (for ([x (list x-offset (+ x-offset (/ size 2)))]
#:when #t
[y (list y-offset (+ y-offset (/ size 2)))])
(send dc draw-rectangle x y (/ size 2) (/ size 2

(define canvas
  (new canvas%
   [parent frame]
   [paint-callback paint]))

(send frame show #t)

-- 
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/ef44708d-8938-4a57-b2d7-576b02bdd8f3n%40googlegroups.com.