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

README is unclear #24

Open
emmanuelHa opened this issue Mar 29, 2023 · 4 comments
Open

README is unclear #24

emmanuelHa opened this issue Mar 29, 2023 · 4 comments

Comments

@emmanuelHa
Copy link

I think that the readme misses some examples to understand the correct syntaxes.
It would be helpfull to give example for each flags and the corresponding schema used for each use case.
Thanks !

@C0urante
Copy link

There's already tons of examples in the README, what specifically do you think should be added?

@emmanuelHa
Copy link
Author

emmanuelHa commented Mar 29, 2023

You could for example document the way this works through use cases from command line.
As a user I want to use not to guess the way it works.
A simple usage is for example :
./arg -f ../yourSchema.json --json -o output.json -i 10
where yourSchema.json could be something like :

{
  "type": "record",
  "name": "options_test_record",
  "fields": [
    {
      "name": "myUuid",
      "type": {
        "type": "string",
        "arg.properties": {
          "regex": "[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}"
        }
      }
    },
    {
      "name": "myEnumType",
      "type": {
        "type": "enum",
        "name": "enum_test",
        "symbols": [
          "MY_VALUE_1",
          "MY_VALUE_2",
          "MY_VALUE_3"
        ],
        "arg.properties":
          {
            "options": [
              "MY_VALUE_1",
              "MY_VALUE_2",
              "MY_VALUE_3"
            ]
          }
      }
    },
    {
      "name": "myNumber",
      "type": {
        "type": "int",
        "arg.properties": {
          "range" : {"min": 1, "max": 10}
        }
      }
    }
  ]
}

May be I missused the enum type but I was surprised to see I had to add both 'symbols' and 'options' fields.
I would have thought to define the different values of the enum, the name of the field and the library would need nothing more to generate the data.
In this example we defined an input example and to make it clear we would need to show the output.

Does it make sense ?

@C0urante
Copy link

Ah, CLI examples could be useful.

With regards to the enum example--are you familiar with Avro at all? Because that's a bit of a prerequisite for using this tool. We also clearly demonstrate here that you do not need to specify a value for options when using an enum, and here we show that, when you do, it can be used to narrow down which enum values are emitted by the generator.

@emmanuelHa
Copy link
Author

I did some Avro yes.
Thank you I saw that it was possible to narrow down the number of values of the source Enum, but I find it weard actually.
I guess it could be used when you dynamically change your schema file depending on a specific use case.
Finally as you said I did not need the options part, it works great thank you!

"arg.properties":{
            "options": [

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

No branches or pull requests

2 participants