News for hackers. Stuff that matters.
Re:Gooey: Turn almost any Python command line program into a... by goostavos on Saturday December 09, 2023 @07:39PM (#38587791)
Hey, what the -- this is my thing. ^_^ What's it doing at the top of HN?

A quick reply to some of the comments about argparse. Gooey is super old at this point. Argparse was a solid choice at the time when Gooey started. These days, Gooey itself speaks in JSON and is decoupled from argparse itself. However, argparse remains the main "blessed" interface (mostly because nobody else has built a different one).

Some fun FYIs: You can also invoke any arbitrary executable[0], not just python, which is pretty handy.

Re: last commit being 2 years ago. It gets harder to justify working for free on niche software as you get older and priorities change :( If it's any consolation, I DO feel guilty all the time. I have no idea why, but where I live, there's "GOOEY" graffiti tagged all over the place, so it's a nice ever-present reminder of the issue tracker that's currently going unloved. haha.

[0] https://chriskiehl.com/article/gooey-as-a-universal-frontend

Re:Gooey: Turn almost any Python command line program into a... by elteto on Saturday December 09, 2023 @08:29PM (#38588122)
Hey! Cool project! I have a question: why do you dump out sys.argv to a local file in the CWD? [0] tmp.txt is hardly a unique name… or am I missing something?

[0] https://github.com/chriskiehl/Gooey/blob/be4b11b8f27f500e732...

Re:Gooey: Turn almost any Python command line program into a... by hiatus on Saturday December 09, 2023 @09:44PM (#38588537)
Seems like it's potentially used for debugging, especially given that pycharm apparently appends additional params when invoking a new process (as noted in the comment at the top of the file).
Re:Gooey: Turn almost any Python command line program into a... by seeknotfind on Saturday December 09, 2023 @07:56PM (#38587910)
This is a really cool idea. I love interface disconnected from APIs. We have so many annoyances these days because applications can't be programmatically controlled. Honestly, I'd like to see legislation saying all application functionality needs to have APIs.
Re:Gooey: Turn almost any Python command line program into a... by sezna on Saturday December 09, 2023 @10:39PM (#38588816)
I would not like to have to concern myself with exposing government-compliant APIs when coding any arbitrary tool...the free market can reward good development.
Re:Gooey: Turn almost any Python command line program into a... by dimask on Sunday December 10, 2023 @04:56AM (#38590482)
> the free market can reward good development

ha ha

No way, especially because all the people taking most market-business-related decisions (eg which software to buy) are not tech-oriented. If we had more power on these decisions, that would mean that development, and even advertising of products, would be closer to what the parent comment suggest. But alas.

Re:Gooey: Turn almost any Python command line program into a... by treyd on Sunday December 10, 2023 @11:49AM (#38592852)
> the free market can reward good development.

Markets cannot regulate nuanced behavior like this. Microsoft is a trivial example of anti-user practices and generally garbage design nonetheless being adopted due to their tremendous efforts of corporate propaganda and scaremongering the decision makers about their products.

Re:Gooey: Turn almost any Python command line program into a... by cdogl on Sunday December 10, 2023 @03:33AM (#38590097)
> Honestly, I'd like to see legislation saying all application functionality needs to have APIs.

The security implications of this give me heart palpitations.

Re:Gooey: Turn almost any Python command line program into a... by sroussey on Sunday December 10, 2023 @12:53PM (#38593352)
The opportunities for abuse are manifold.
Re:Gooey: Turn almost any Python command line program into a... by seeknotfind on Sunday December 10, 2023 @01:59PM (#38593873)
This is true, but the abuse would still be possible today if someone is reverse engineering software or talking to servers where everything is over APIs anyway. I'm talking about local interface decoupled with a local API from implementation. The problem today is that programmers can't compose or build software on top of other software they have.
Re:Gooey: Turn almost any Python command line program into a... by cdogl on Monday December 11, 2023 @01:31AM (#38598166)
> I'm talking about local interface decoupled with a local API from implementation.

To expose this "local API" usefully, you must either:

1. Share memory with other processes (new attack vector), or 2. Listen on some kind of network or native socket for messages and authn+authz the commands that come through it based on some security protocol (new attack vector).

The value proposition of an API is to allow control and data flow between an application and some external entity. It seems to me that it has security implications by definition.

Re:Gooey: Turn almost any Python command line program into a... by elbear on Sunday December 10, 2023 @03:45AM (#38590152)
Maybe think of incentives rather than legislation
Re:Gooey: Turn almost any Python command line program into a... by rocqua on Sunday December 10, 2023 @04:32AM (#38590350)
I think legislation demanding most tools have an API would be a good thing. Not 'tho shalt expose a REST endpoint'. But instead something like 'every operation a user can do with this tool, they also need to be able to trigger with an interface that is programable, and that interface needs to be documented'.

Saying 'our programable interface is the gui, use autohotkey' is fine, as long as you properly document all click regions.

This would be a massive productivity boost to anyone using such tools. It would also be great for disabled people.

Re:Gooey: Turn almost any Python command line program into a... by linsomniac on Saturday December 09, 2023 @08:44PM (#38588218)
Argparse is still a pretty solid choice, because it's so ubiquitous and well documented and fairly easy. Typer and Click are both very nice, with some good ergonomics, but I find Typer's "tutorial" style documentation to be rather hard to search to find answers to things like "What arguments does Typer.App() take?"

I have a program I'm working on right now that does user-initiated argument parsing, and argparse is a great fit for it. I'd love to have a text-based UI as an option to drop users into, but Textualize requires Click (IIRC), and using Textual directly in my code to create the UI I've spent hours on and had absolutely no luck even getting started.

Re:Gooey: Turn almost any Python command line program into a... by zelphirkalt on Sunday December 10, 2023 @05:20AM (#38590583)
While Typer looks nice, I found it to be annoying. It outputs everything depending on the width of your terminal emulator with spaces instead of newlines. Not sure who thought that was a good idea, but try copy pasting any output of it in any chat or anywhere that is not the same width in chars as your terminal emulator. The output becomes complete shit and unreadable. The second thing is, that it forces you to adhere to its paradigm of being a global mutable state object, instrad of being passed around neatly like argsparse, which makes code less understandable and tests needlessly more complicated.

Overall I have found it to be very much not worth it adding typer as a dependency. Hard pass.

Re:Gooey: Turn almost any Python command line program into a... by linsomniac on Sunday December 10, 2023 @01:12PM (#38593516)
On the other hand, I've switched to using Typer for most of my argument parsing because it's not an object I have to pass around. It lets me have the arguments co-located with the code, which is convenient. Especially for more complicated argument parsing, like one of my commands for our deploy process which has maybe 15 sub-commands, that sort of parsing with argparse is kind of a nightmare.
Re:Gooey: Turn almost any Python command line program into a... by zelphirkalt on Monday December 11, 2023 @03:58AM (#38598842)
The solution to this kind of issue is something like parameters (See for example https://www.gnu.org/software/guile/manual/html_node/Paramete...). They are also thread safe. One can easily set them in tests without having to mock things. I am not sure it is possible to even have something like this in Python. Have not seen it anywhere in Python.

> Passing arguments to functions is thread-safe, but that soon becomes tedious when there’s more than a few or when they need to pass down through several layers of calls before reaching the point they should affect. Introducing a new setting to existing code is often easier with a parameter object than adding arguments.

But also, if you really wanted to, you could set the argsparse object to a global variable and then import it everywhere else. So that is not a limitation.

Re:Gooey: Turn almost any Python command line program into a... by linsomniac on Monday December 11, 2023 @10:27AM (#38601437)
My issue with argparse isn't that it's not global, it's that you have to create sub-parsers for multiple commands, and then add arguments to those subparsers. Those parsers are all typically defined in a central location, but copying arguments between those parsers as I define new commands can get them jumbled up because the sub-parser comes along with the argument:

    sub1 = [create subparser]
    sub1.add_argument('-x')
    sub2 = [create subparser]
If I copy "sub1.add_argument" and put it under "sub2", and forget to change "sub1" to "sub2", it is a hard to track down bug. I've had this happen a lot as the parser gets more complex.

Typer completely eliminates this potential bug, because the arguments are defined as type annotations in the sub-command function itself.

Re:Gooey: Turn almost any Python command line program into a... by voidnap on Monday December 11, 2023 @11:09AM (#38601807)
Gee if only there was a way to reuse logic within a program.

> arguments are defined as type annotations in the sub-command function itself

So you duplicate logic in your type definitions instead of as instructions. Whatever makes you happy i guess.

Re:Gooey: Turn almost any Python command line program into a... by pletnes on Sunday December 10, 2023 @06:32AM (#38590854)
Notably, argparse is way faster than click/typer. If you just need a few —options it’s probably preferable.
Re:Gooey: Turn almost any Python command line program into a... by mkesper on Sunday December 10, 2023 @10:21AM (#38592098)
Argparse also does not require tens of external libraries.
Re:Gooey: Turn almost any Python command line program into a... by fbdab103 on Sunday December 10, 2023 @12:06PM (#38593000)
That right there is the real winner. I already get queasy when my dependency list gets too long. Invoking an extra collection for what is mostly developer quality of life is not a trade-off I like to make.
Re:Gooey: Turn almost any Python command line program into a... by e40 on Sunday December 10, 2023 @05:09AM (#38590550)
Graffiti?? Where do you live? Any pics of it?
Re:Gooey: Turn almost any Python command line program into a... by brookst on Sunday December 10, 2023 @11:18AM (#38592568)
Presumably Seattle; Gooey is a prolific tagger. This appears to be their instagram: https://www.instagram.com/gooeygue/
Re:Gooey: Turn almost any Python command line program into a... by rollcat on Sunday December 10, 2023 @06:41AM (#38590889)
> These days, Gooey itself speaks in JSON and is decoupled from argparse itself.

This sounds cool. I saw the headline and before clicking anything, my first thought was "bet this heavily depends on argparse", so this is surprising - in a very nice way.

I'm a hardcore getopt fan, mostly because I believe the developer's convenience is nowhere as important as the convenience of the user, and the user shouldn't need to care what programming language or option parsing library the developer chose. argparse, Click, Go's flag/X11-style, and many other similar libraries break conventions that are ingrained in half a century's collective muscle memory.

But with a layer in the middle, it sounds like you can eat your cake and have it too.

Re:Gooey: Turn almost any Python command line program into a... by puzzlingcaptcha on Sunday December 10, 2023 @08:04AM (#38591278)
> Gooey is super old at this point.

It's only super old because you abandoned it (and I don't mean to be judgemental, it is what it is). Worse yet, no viable alternative has shown up to replace it nor either of its forks gained traction.

Re:Gooey: Turn almost any Python command line program into a... by DontchaKnowit on Monday December 11, 2023 @04:01PM (#38605454)
No its super old cause it was created a long time ago? Why dont you go update it or make a free up to date version? Why do people act like software creators owe the world something?
Re:Gooey: Turn almost any Python command line program into a... by puzzlingcaptcha on Wednesday December 13, 2023 @03:42AM (#38624392)
And Python itself was released in 2000! No wonder everyone has abandoned it these days, it's ancient!
Re:Gooey: Turn almost any Python command line program into a... by c6401 on Sunday December 17, 2023 @09:43AM (#38673163)
Thank you for your work, awesome software.

I'm wondering if there's a way to use python-fire instead of argpraser with gooey?