cutefetch icon indicating copy to clipboard operation
cutefetch copied to clipboard

feat: add randomizer function

Open cybardev opened this issue 2 years ago • 5 comments

Description

We want a function in the script that uses shuf to randomize the animals and eyes. Currently we only have a note under the Extras section in the readme.

Code suggested by @Kalitsune in https://github.com/cybardev/cutefetch/issues/8#issuecomment-1813084243:

# welcome screen
fetch () {
  eyes=(0 1 2 3 4 6 7 8 11 12 14)
  cutefetch -k2 $(shuf -e "${eyes[@]}" -n 1)
}
fetch

This radomizes the eyes but not the animal. Ideally, we would also randomize the animal. Optionally, we can make it a flag with args, like -r eyes and -r animal, with the default -r and -r all having both effects.

Changes Requested

  • add randomizer function called randomfetch or randfetch (either is fine but I prefer randomfetch since it's more explicit and clear)
  • use two lists: one for eyes, one for animal
  • add randomizer flag that takes optional args to randomize eyes or animal
  • flag default (without args) should be to randomize both

Acceptance Criteria

  • randomizes animal with -r animal and --random animal flags
  • randomizes eyes with -r eyes and --random eyes flags
  • randomizes both with -r, -r all, --random, and --random all flags
  • existing features are unaltered and continue to work

Blockers

  • Blocks: N/A
  • Blocked-by: #10

cybardev avatar Nov 16 '23 13:11 cybardev

Suggestion: Replacing the --animal argument by an option:

cutefetch <animal> <eyes>

(It doesn't make sense to have a --flag for this if you cant print two animals at once)

And accepting arrays as input:

cutefetch (bunny,kitty,doggy) (0, 1, 5, 12)

And if an array is passed as an input, have the program choose a random value in it

Of course, this could still be used without using the random feature like this:

cutefetch kitty2 12

Kalitsune avatar Nov 16 '23 14:11 Kalitsune

That makes a lot of sense. Thanks for the suggestions, @Kalitsune. I think changing the flags to args should be another issue since this issue is just about the randomizer, so I'll make a separate issue on that sometime soon.

Also, we should probably still have a "randomize from all" flag or argument, or maybe if <animal> and <eyes> are given "random" then we randomize that. Cuz it'd be cumbersome to list all available animals and eyes in args.

cybardev avatar Nov 16 '23 15:11 cybardev

Sure. But if we're planning on changing the args its probably better not to start implementing the random yet to avoid having to reimplement it once the change is done

And yes, using "random" as an arg for randomize all makes a lot of sense we should do that!

Kalitsune avatar Nov 16 '23 15:11 Kalitsune

Alright. In that case, you can hold off making the randomizer for now in case you were planning to work on it.

I'll make a PR with the new argument parsing system and let you know when it's ready.

Thanks for your help and insight on these issues. Enjoy your day(s) 😊

cybardev avatar Nov 16 '23 17:11 cybardev

Thanks! You too! Good working on it!

On Thu, Nov 16, 2023, 6:07 PM Sheikh @.***> wrote:

Alright. In that case, you can hold off making the randomizer for now in case you were planning to work on it.

I'll make a PR with the new argument parsing system and let you know when it's ready.

Thanks for your help and insight on these issues. Enjoy your day(s) 😊

— Reply to this email directly, view it on GitHub https://github.com/cybardev/cutefetch/issues/9#issuecomment-1814869136, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARVE2BNIXJCD4E3ZZPFFJT3YEZB3JAVCNFSM6AAAAAA7OFGXL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJUHA3DSMJTGY . You are receiving this because you were mentioned.Message ID: @.***>

Kalitsune avatar Nov 16 '23 17:11 Kalitsune