nickbabcock / jomini

Parses Paradox files into javascript objects
MIT License
78 stars 9 forks source link

Command line version? #80

Closed Smashman closed 2 years ago

Smashman commented 2 years ago

I think a command line way of using this library would be an excellent extension.

nickbabcock commented 2 years ago

Yeah I'm open to the idea. Anything in particular you had in mind? Is there another library that offers a command line interface

nickbabcock commented 2 years ago

Feel free to continue the convo

Smashman commented 2 years ago

I was thinking utilising npx to one-time convert a gamestate file.

For example: npx jomini gamestate stellaris-save-one

Would output the converted contents of the gamestate file in the current directory to a file named stellaris-save-one.json in the same place.

Here's some info on npx.

The yargs package be used to get arguments passed to the CLI.

Finally, the bin property of a package.json desigates a file as executable to npm. So a .js file can be passed here and run when npx is executed.

Let me know if you have further questions.

nickbabcock commented 2 years ago

Thanks for clarifying. I like this idea, and I think this should be implemented. It may not be implemented in this repo as this is more of a wrapper library for js users, and so I think I'd bake the json conversion cli functionality into more of a single toolkit, so it's a one stop shop (and one wouldn't need to worry about having node.js installed to run it).

nickbabcock commented 2 years ago

I created a json subcommand in the toolkit I mentioned: https://github.com/rakaly/cli#conversion-to-json , so that should be enough to get a taste!