mplanchard / cuid-rust

Rust implemention of CUID unique IDs
https://crates.io/crates/cuid
MIT License
91 stars 15 forks source link

Support changing the length of the generated ID with cuid2 binary #13

Closed der-fruhling closed 2 months ago

der-fruhling commented 1 year ago

This PR adds an argument to the cuid2 binary that allows changing the length of the generated ID from it's default.

# Original behavior
$ cuid2
ali0e7b9ryfeexl0b7akyb6v

# New behavior
$ cuid2 32
cqyxwxhpy3qyk1njfzq9jpf8b1s0ftkp
mplanchard commented 4 months ago

Wow, sorry for the super late reply on this! I guess the notification got lost in my email :facepalm:

Anyway, I like the idea of having an argument to specify the length, but I'd prefer it be a short/long option with dashes, -l or --length I think would be good.

der-fruhling commented 4 months ago

Thanks for the reply! I've changed it to be an argument, and had to rework the argument parsing a bit to accept values.

The new syntax is as you described, cuid2 --length 64 / cuid2 -l 64.

mplanchard commented 2 months ago

Thanks for the MR! Merging. Will look into getting a new release out soon