You should be able to call the Windows APIs directly (if you can figure out
which ones!) and avoid using a script to call a binary.

On Tue, Oct 25, 2016 at 1:02 PM Alexander Ilin <ajs...@yandex.ru> wrote:

> The same, but a bit more elaborate (and hopefully more readable):
>
> USING: documents.private io io.encodings.utf8 io.launcher kernel
> math sequences sets splitting ;
> IN: other
>
> ! Find the header line in the sequence and return it with its number.
> : find-header ( lines -- num/f line/f )
>     [ members "= " = ] find ;
>
> ! Convert header line to column widths: "=== == =" -> { 3 2 1 }.
> : column-widths ( line -- seq )
>     [ CHAR: space = ] split-when harvest [ length ] map ;
>
> : table-contents ( lines header-line-num -- lines' )
>     1 + tail harvest ;
>
> : first-column ( lines column-widths -- lines' )
>     first [ head [ CHAR: space = ] trim ] curry map ;
>
> : user-groups ( -- seq/f )
>     "whoami /groups" utf8 [ contents ] with-process-reader split-lines
>     dup find-header
>     [
>         [ table-contents ] dip column-widths first-column
>     ] [ 2drop f ] if* ;
>
> 25.10.2016, 00:51, "Alexander Ilin" <ajs...@yandex.ru>:
>
> Here's a small utility for you:
>
> USING: io.launcher io.encodings.utf8 sequences sets documents.private ;
> : user-groups ( -- seq/f )
>     "whoami /groups" utf8 [ contents ] with-process-reader split-lines
>     dup [ members "= " = ] find
>     [
>         [ 1 + tail ] dip
>         [ CHAR: space = ] find drop
>         [ harvest ] dip
>         [ head [ CHAR: space = ] trim ] curry map
>     ] [ 2drop f ] if* ;
>
>
> Usage:
>
> "Administrators" user-groups in?
> -> `t`
>
> ---=====---
> Александр
>
>
> ,
>
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik
>
> ,
>
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ---=====---
> Александр
>
>
> ------------------------------------------------------------------------------
> The Command Line: Reinvented for Modern Developers
> Did the resurgence of CLI tooling catch you by surprise?
> Reconnect with the command line and become more productive.
> Learn the new .NET and ASP.NET CLI. Get your free copy!
> http://sdm.link/telerik_______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to