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

Basic randomization implementation. #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

EddieDover
Copy link
Collaborator

This is a pretty simple implementation that choose a random screen on --random. I figure, in the future, when people want to have this auto-launch somehow, randomizing the selected screen per run might be fun.

It chooses from one of the following screens that do not require parameters:

  • asciiartfarts
  • clocks
  • jokes4all
  • matrix
  • quotes4all
  • rfc
  • starwars
  • sysmon
  • wttr

@@ -156,7 +174,8 @@ def getScreen():

# Assign the important arguments on module init.
verbose = True if args.verbose else False
if args.screen == None or (args.screen == None and args.help == True):
use_random = True if args.random else False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parser addition you made already takes care of this check with the "default" option... both the verbose and the rnadom should be just used as is from 'args'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this was done before that PR was merged, so I was trying to not use its functionality. Been a while since I've thought about it.

@@ -131,6 +132,22 @@ def entryPoint():

def getScreen():
verbose = False
use_random = False
available_random_screens = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to hard code the screen as opposed to use the get_available_screens? (this one checks the file system instead so you would not have to do this manually)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original intent was, so we could limit the random screens to omit any potential NSFW screens. Perhaps we could move that into a flag for the screens themselves instead?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, that looks better.

for s in get_available_screens():
# Create the parsers for each screen.
parsers[s.__name__.lower()] = screenparsers.add_parser(s.__name__.lower(), formatter_class=SmartFormatter, conflict_handler='resolve')
if s().name.lower() == args.screen:
screen = s
if use_random is False:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in line 189 you could just choose to override the args.screen value so then you don't need to change anything in the code below (confirming again the random argument within the available screens loop)... what do you think?

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

Successfully merging this pull request may close these issues.

2 participants