Created
January 3, 2013 00:00
-
-
Save ryanbraganza/4439548 to your computer and use it in GitHub Desktop.
django management command to greet cindy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.management.base import BaseCommand, CommandError | |
| from optparse import make_option | |
| class Command(BaseCommand): | |
| args = "<how many times to say hi to cindy>" | |
| help = "Says hi to Cindy" | |
| option_list = BaseCommand.option_list + ( | |
| make_option('--with-smily-face', | |
| action='store_true', | |
| dest='with_smily_face', | |
| default=False, | |
| help='Add a smily face on each greeting', | |
| ), | |
| ) | |
| def handle(self, num_times, **options): | |
| with_smily_face = options['with_smily_face'] | |
| for _ in range(int(num_times)): | |
| if with_smily_face: | |
| print "hi Cindy :)" | |
| else: | |
| print "hi Cindy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment