love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
4.88k stars 391 forks source link

Support -h/--help cli flags #1735

Closed gvanem closed 1 year ago

gvanem commented 2 years ago

I first heard of Love2D today. Downloading the Win release .zip and trying it required some effort (no real instructions in the readme.txt). For example:

lovec.exe -h
Error: [string "boot.lua"]:577: Cannot load game at path 'F:/MingW32/src/Games/Love2D/-h'.
Make sure a folder exists at the specified path.
...

(same with love.exe -h).

Reading the Wiki, copy & paste the sample to hello-world.lua and running lovec.exe hello-world.lua gave me same bleeding stupid Lua call-stack.

Then voila renaming hello-world.lua to main.lua and running lovec.exe . gave what I'd expect.

How hard should it be? Please handle a -h / --help option like any program with some respect for itself would.

slime73 commented 2 years ago

It might make sense to print a stripped down version of what's in the Getting Started wiki page, when --help is passed in.

However, since you apparently already read the wiki (where that page says to name your file main.lua and pass in the folder containing the file) before you did something that isn't that, I'm not sure it would have helped you.

We'd also need to be careful to avoid preventing games from implementing their own help arguments, if that's desired.

marcotrosi commented 2 years ago

I agree, but confusing title for this issue. "Support -h/--help cli flags"

gvanem commented 2 years ago

I agree, but confusing title for this issue.

Done.

gvanem commented 2 years ago

However, since you apparently already read the wiki

I read this: https://love2d.org/wiki/Main_Page which says: Running this code will cause an 800 by 600 window to appear, and display white text on a black background.

It does not mention how. Hence my confusion since I only skimmed some other Wiki pages.

radgeRayden commented 2 years ago

We'd also need to be careful to avoid preventing games from implementing their own help arguments, if that's desired.

This could be a conf.lua setting. Whether to intercept --help.

hahawoo commented 2 years ago

Running love.exe hello-world.lua intuitively seems like it should work, and not only does it not work but there's no way to learn from the command line what to do.

(I think that this particular instance of confusion could have been prevented with improved documentation, but my opinions on documentation are beyond the scope of this issue.)

That said, I'm not sure about this proposal.

When would this help message be shown? Only when -h/--help is passed? What about love.exe hello-world.lua? If so, this would mean that LOVE project directories couldn't end in ".lua" (or be "-h" for that matter). What about when just love.exe is run with no arguments? I guess this would still have to run the no-game screen as well, since love.exe could also be run from the OS GUI.

Also, how much information would one want --help to give? For a command line program, --help should, if possible, give enough information to use it, but LOVE isn't really a command line program like this; as far as I know it can only be used from the command line in one way: love.exe path-to-project (or two ways if you count love.exe --version). I could imagine something like:

Usage: "love <project-folder>", where "project-folder" is a path to a folder containing a file named "main.lua".

It seems to me that any information beyond this would be better presented elsewhere.

But, LOVE kind of already does this with the error message:

Make sure a folder exists at the specified path.

In summary:

Regarding avoiding preventing games from implementing their own help arguments, does LOVE currently prevent games from implementing their own --version argument?

MikuAuahDark commented 2 years ago

We have separate issue tracker for support of opening main.lua Lua files: #1591

I think we shouldn't intercept --help after the game path is passed. So, love --help will show the help information, but love mygame --help will pass --help as-is to love.load for games to handle.

slime73 commented 1 year ago

commit 019156e addresses this.