Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI script for streaming #88

Open
pkoppstein opened this issue Oct 12, 2022 · 8 comments
Open

CLI script for streaming #88

pkoppstein opened this issue Oct 12, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@pkoppstein
Copy link

pkoppstein commented Oct 12, 2022

@halaxa asked me to start a new thread stemming from the discussion at #73

Hopefully the script described below, which I'll call jm, will provide a basis for discussion or perhaps even the foundation of a script worthy of inclusion in the JSON Machine repository.

The --help option produces quite extensive documentation, so for now I'll just add two points:

  1. The script attempts to make installation as painless as possible for the uninitiated, and I hope that further enhancements in that regard will be added;
  2. Ideally, the script would preserve the precision of all JSON numbers (at least as the default) -- see Option or method for preserving the precision of numeric literals #87

[ EDIT: The jm script is now in the "jm" repository. ]

@halaxa
Copy link
Owner

halaxa commented Oct 12, 2022

Thank you. I'm already prototyping the CLI. You really put an effort into the help. May I alternatively use some parts of it?

@pkoppstein
Copy link
Author

Of course, that's why I've posted here!

@halaxa
Copy link
Owner

halaxa commented Oct 12, 2022

;)

@pkoppstein
Copy link
Author

@halaxa -- Assuming (as I do) that the default encoder should be the PassThruDecoder, should there be an option to use the standard one? If so, what should it be called? Since the main point would be to convert JSON numbers to their PHP equivalent, I'm thinking of "--recode" or perhaps "--php". I think any any variation of encode or decode would be too confusing. Your thoughts?

@pkoppstein
Copy link
Author

pkoppstein commented Oct 13, 2022

Here's jm Version 0.0.5, which uses the PassThruDecoder to preserve numeric literals. It also has the side-effect of allowing mal-formed JSON, but maybe that's not such a bad thing?

[ EDIT: The version originally referenced (i.e., using the PassThruDecoder) can be viewed here at the jm repository ]

@halaxa halaxa changed the title ER: CLI script for streaming CLI script for streaming Oct 13, 2022
@halaxa halaxa added the enhancement New feature or request label Oct 13, 2022
@pkoppstein
Copy link
Author

The jm script now has a bunch of options making it quite a handy tool for a variety of tasks. jm --help gives detailed help. Here's the output of jm -h:

Usage: jm [ OPTIONS ]  [ FILEPATH ... ]
or:    jm [-h | --help]
where JSONPOINTER defaults to '' and FILEPATH defaults to stdin, and the other options are:
     -s
     --array
     --bigint_as_string | --recode
     --count | --limit=LIMIT
     --pointer=JSONPOINTER

@halaxa
Copy link
Owner

halaxa commented Oct 15, 2022

Thanks for the hints. The count option is a good idea. The version I'm currently working on will also include tests and offer extensibility to some degree. I hope the PR will land soon. I'll appreciate your feedback then.

@pkoppstein
Copy link
Author

I'm adding a --version option to jm and would like to include the JSON Machine version number, but I don't see an easy way to report it reliably. Searching for the version string in CHANGELOG.md doesn't seem either efficient or reliable.

Could perhaps JSON Machine provide a function to report its version number?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants