Results 1 to 10 of 10

Thread: [Minor] macOS Application Bundle CLI Support

  1. #1

    Default [Minor] macOS Application Bundle CLI Support

    macOS application bundles are meant to be usable with both a GUI and CLI, if they are available.

    The GUI, of course, is launched by opening the (ApplicationName).app bundle in Finder, or using the ďopenĒ command in a shell. CLIs are usually accessed by running the raw binary at (ApplicationName).app/Contents/(BinaryName, which might be different).

    In the case of KoLmafia, that binary is JavaApplicationStub. I can launch it from the command line just fine, and I can see System.out and System.err normally. Unfortunately, unlike the JAR build, it just launches the GUI instead of accepting arguments.

    I understand this is a very small issue, since users can just keep two copies of KoLmafia around, or just use a JAR for everything. But it may not be that hard to implement, and it would be very convenient. Iím not too familiar with Ant, so it might even be a matter of changing a setting somewhere.

  2. #2
    Senior Member
    Join Date
    Oct 2014
    Posts
    150

    Default

    Can't you just run the jar from the terminal?

    Something like: java -jar -Djava.awt.headless=true -XX:+PrintGCDetails Desktop/KoLmafia-18559M.jar

  3. #3

    Default

    As I said, itís possible to just keep the JAR around as well. Thereís a reason I denoted this as minor. This is a nice-to-have, nothing more.

  4. #4
    Senior Member
    Join Date
    Oct 2014
    Posts
    150

    Default

    As I said, it’s possible to just keep the JAR around as well. There’s a reason I denoted this as minor. This is a nice-to-have, nothing more.
    Originally Posted by Saklad5 View Post
    Ah, I see where I was confused. I only use the JAR (whether I want the GUI or not) but apparently you can get it in different packaging.

  5. #5
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    3,994

    Default

    But it may not be that hard to implement, and it would be very convenient. I’m not too familiar with Ant, so it might even be a matter of changing a setting somewhere.
    Originally Posted by Saklad5 View Post
    All the devs (and many other people as well) can build a jar. But the Mac specific "packaging" done for "official releases" (dmg file) can only be done by a couple of people. OS specific code tends to be avoided unless it makes life easier for a dev with that OS or the lack of such code breaks KoLmafia functionality.

    With that background, you might consider telling us what has to change to give you what you want. Does the dmg file do what you want? If so then this is really a request that the DailyBuilds also include dmg files as well as jars. If I have all the Java class files, can you tell me the commands to package them to give you what you want? If so then it might be reasonably simple to add another target to the build file. Does the source code need to be modified to introduce a new class? If so, what is the class and what should it do?

    I'm also not sure why "keeping the jar" around is an issue. What are you downloading or building, if not the jar? How do you transform it to get what you want?
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  6. #6

    Default

    I build the .app bundle from the source code using Apache Ant with the jarbundler instruction that is included in the build file. That already uses OS-specific code, as does the exe for Windows.

    If I knew how to do this myself, I would do so and submit a patch. I don’t, unfortunately, so I can only ask if anyone else does. As I said in the first post of this thread, running the binary inside the application bundle on the command line launches the GUI while showing console output. I understand that the JAR will actually allow user input on the command line if run that way. I want the binary to act the same.

    The DMG is just a disk image that contains a .app bundle, by the way. It isn’t a distinct thing.

    I’m sorry if this isn’t clear, I’m not sure how to better explain it.

  7. #7
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    3,994

    Default

    Iím sorry if this isnít clear, Iím not sure how to better explain it.
    Originally Posted by Saklad5 View Post
    It is not necessarily you. My knowledge of Mac specific tools and conventions and vocabulary is non-existent.

    Uncle Google suggests that the behavior you want is controlled by JavaApplicationStub which is provided by the (development) build environment. Uncle Google also suggests that "default" JavaApplicationStub files are Java and OS specific. I'm not going to go down that rabbit hole with only Windows and Linux to play with.

    It would be helpful if a Mac dev would execute the jarbundler task and run the result. If it behaves as you describe (and don't want) then the task probably needs to be tweaked, possibly by using a mafia provided JavaApplicationStub equivalent. If it behaves differently then the solution lies in the differences between the two Mac environments.

    All that said, I think your only solution is going to be to keep the jar around unless someone else gets interested.
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post

  8. #8

    Default

    …I’m an idiot. I just realized some of the guides had the --CLI flag after the JAR. Sure enough, adding that flag after the application binary let me access the KoLmafia CLI. In other words, it already works as I want: the only issue is that all the guides incorrectly say that only the JAR can do that.

    I’m willing to bet the output-only state I described also occurs if you run the JAR from the command line without that flag.

  9. #9

    Default

    For future reference, macOS users can access the CLI by running:

    {Path of KoLmafia application bundle}/Contents/MacOS/JavaApplicationStub --CLI

    in a shell of your choice.

  10. #10
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    Central Virginia, USA
    Posts
    3,994

    Default

    Glad we all learned something.

    I did make an error above. KoLmafia does have a version of JavaApplicationStub that is managed and provided by KoLmafia.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •