Switch to the option group pattern for API examples.
(imported from commit 67d0164df822a56f06d5f959297cc2efa9706001)
This commit is contained in:
		
							parent
							
								
									ea27fbae11
								
							
						
					
					
						commit
						f1d60f5417
					
				
					 6 changed files with 34 additions and 63 deletions
				
			
		|  | @ -31,18 +31,14 @@ Prints out all the public streams in the realm. | ||||||
| 
 | 
 | ||||||
| Example: get-public-streams --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: get-public-streams --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
| parser = optparse.OptionParser(usage=usage) |  | ||||||
| parser.add_option('--site', default='https://humbughq.com') |  | ||||||
| parser.add_option('--api-key') |  | ||||||
| parser.add_option('--user') |  | ||||||
| (options, args) = parser.parse_args() |  | ||||||
| 
 | 
 | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
| import humbug | import humbug | ||||||
| client = humbug.Client( | 
 | ||||||
|     email=options.user, | parser = optparse.OptionParser(usage=usage) | ||||||
|     api_key=options.api_key, | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
|     verbose=True, | (options, args) = parser.parse_args() | ||||||
|     site=options.site) | 
 | ||||||
|  | client = humbug.init_from_options(options) | ||||||
| 
 | 
 | ||||||
| print client.get_public_streams() | print client.get_public_streams() | ||||||
|  |  | ||||||
|  | @ -31,18 +31,13 @@ Prints out a list of the user's subscriptions. | ||||||
| 
 | 
 | ||||||
| Example: list-subscriptions --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: list-subscriptions --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
| parser = optparse.OptionParser(usage=usage) |  | ||||||
| parser.add_option('--site', default='https://humbughq.com') |  | ||||||
| parser.add_option('--api-key') |  | ||||||
| parser.add_option('--user') |  | ||||||
| (options, args) = parser.parse_args() |  | ||||||
| 
 |  | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
| import humbug | import humbug | ||||||
| client = humbug.Client( | 
 | ||||||
|     email=options.user, | parser = optparse.OptionParser(usage=usage) | ||||||
|     api_key=options.api_key, | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
|     verbose=True, | (options, args) = parser.parse_args() | ||||||
|     site=options.site) | 
 | ||||||
|  | client = humbug.init_from_options(options) | ||||||
| 
 | 
 | ||||||
| print client.list_subscriptions() | print client.list_subscriptions() | ||||||
|  |  | ||||||
|  | @ -31,19 +31,14 @@ Prints out each message received by the indicated user. | ||||||
| 
 | 
 | ||||||
| Example: print-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: print-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
| parser = optparse.OptionParser(usage=usage) |  | ||||||
| parser.add_option('--site', default='https://humbughq.com') |  | ||||||
| parser.add_option('--api-key') |  | ||||||
| parser.add_option('--user') |  | ||||||
| (options, args) = parser.parse_args() |  | ||||||
| 
 |  | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
| import humbug | import humbug | ||||||
| client = humbug.Client( | 
 | ||||||
|     email=options.user, | parser = optparse.OptionParser(usage=usage) | ||||||
|     api_key=options.api_key, | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
|     verbose=True, | (options, args) = parser.parse_args() | ||||||
|     site=options.site) | 
 | ||||||
|  | client = humbug.init_from_options(options) | ||||||
| 
 | 
 | ||||||
| def print_message(message): | def print_message(message): | ||||||
|     print message |     print message | ||||||
|  |  | ||||||
|  | @ -31,18 +31,13 @@ Prints out the next message received by the user. | ||||||
| 
 | 
 | ||||||
| Example: print-next-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: print-next-messages --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
| parser = optparse.OptionParser(usage=usage) |  | ||||||
| parser.add_option('--site', default='https://humbughq.com') |  | ||||||
| parser.add_option('--api-key') |  | ||||||
| parser.add_option('--user') |  | ||||||
| (options, args) = parser.parse_args() |  | ||||||
| 
 |  | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
| import humbug | import humbug | ||||||
| client = humbug.Client( | 
 | ||||||
|     email=options.user, | parser = optparse.OptionParser(usage=usage) | ||||||
|     api_key=options.api_key, | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
|     verbose=True, | (options, args) = parser.parse_args() | ||||||
|     site=options.site) | 
 | ||||||
|  | client = humbug.init_from_options(options) | ||||||
| 
 | 
 | ||||||
| print client.get_messages({}) | print client.get_messages({}) | ||||||
|  |  | ||||||
|  | @ -31,20 +31,15 @@ Ensures the user is subscribed to the listed streams. | ||||||
| 
 | 
 | ||||||
| Example: subscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: subscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
|  | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
|  | import humbug | ||||||
|  | 
 | ||||||
| parser = optparse.OptionParser(usage=usage) | parser = optparse.OptionParser(usage=usage) | ||||||
| parser.add_option('--api-key') | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
| parser.add_option('--user') |  | ||||||
| parser.add_option('--site',    default='https://humbughq.com') |  | ||||||
| parser.add_option('--streams', default='') | parser.add_option('--streams', default='') | ||||||
| (options, args) = parser.parse_args() | (options, args) = parser.parse_args() | ||||||
| 
 | 
 | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | client = humbug.init_from_options(options) | ||||||
| import humbug |  | ||||||
| client = humbug.Client( |  | ||||||
|     email=options.user, |  | ||||||
|     api_key=options.api_key, |  | ||||||
|     verbose=True, |  | ||||||
|     site=options.site) |  | ||||||
| 
 | 
 | ||||||
| if options.streams == "": | if options.streams == "": | ||||||
|     print >>sys.stderr, "Usage:", parser.usage |     print >>sys.stderr, "Usage:", parser.usage | ||||||
|  |  | ||||||
|  | @ -31,20 +31,15 @@ Ensures the user is not subscribed to the listed streams. | ||||||
| 
 | 
 | ||||||
| Example: unsubscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | Example: unsubscribe --user=tabbott@humbughq.com --site=https://zephyr.humbughq.com | ||||||
| """ | """ | ||||||
|  | sys.path.append(path.join(path.dirname(__file__), '..')) | ||||||
|  | import humbug | ||||||
|  | 
 | ||||||
| parser = optparse.OptionParser(usage=usage) | parser = optparse.OptionParser(usage=usage) | ||||||
| parser.add_option('--api-key') | parser.add_option_group(humbug.generate_option_group(parser)) | ||||||
| parser.add_option('--user') |  | ||||||
| parser.add_option('--site',    default='https://humbughq.com') |  | ||||||
| parser.add_option('--streams', default='') | parser.add_option('--streams', default='') | ||||||
| (options, args) = parser.parse_args() | (options, args) = parser.parse_args() | ||||||
| 
 | 
 | ||||||
| sys.path.append(path.join(path.dirname(__file__), '..')) | client = humbug.init_from_options(options) | ||||||
| import humbug |  | ||||||
| client = humbug.Client( |  | ||||||
|     email=options.user, |  | ||||||
|     api_key=options.api_key, |  | ||||||
|     verbose=True, |  | ||||||
|     site=options.site) |  | ||||||
| 
 | 
 | ||||||
| if options.streams == "": | if options.streams == "": | ||||||
|     print >>sys.stderr, "Usage:", parser.usage |     print >>sys.stderr, "Usage:", parser.usage | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Luke Faraone
						Luke Faraone