13
13
import sys
14
14
import textwrap
15
15
import warnings
16
+ import webbrowser
16
17
17
18
class PinoutTool (object ):
18
19
def __init__ (self ):
@@ -38,6 +39,12 @@ def __init__(self):
38
39
action = 'store_false' ,
39
40
help = 'Force monochrome output. See also --color'
40
41
)
42
+ self .parser .add_argument (
43
+ '-x' , '--xyz' ,
44
+ dest = 'xyz' ,
45
+ action = 'store_true' ,
46
+ help = 'Open pinout.xyz in the default web browser'
47
+ )
41
48
42
49
def __call__ (self , args = None ):
43
50
if args is None :
@@ -69,23 +76,27 @@ def main(self, args):
69
76
"remotely access your Pi."
70
77
)
71
78
formatter .add_text (
72
- "* https://gpiozero.readthedocs.io/en/latest /remote_gpio.html"
79
+ "* https://gpiozero.readthedocs.io/en/stable /remote_gpio.html"
73
80
)
74
81
sys .stderr .write (formatter .format_help ())
75
82
else :
76
- if args .revision == '' :
77
- try :
78
- pi_info ().pprint (color = args .color )
79
- except IOError :
80
- raise IOError ('This device is not a Raspberry Pi' )
83
+ if args .xyz :
84
+ webbrowser .open ('https://pinout.xyz' )
81
85
else :
82
- pi_info (args .revision ).pprint (color = args .color )
83
- formatter = self .parser ._get_formatter ()
84
- formatter .add_text (
85
- "For further information, please refer to https://pinout.xyz/"
86
- )
87
- sys .stdout .write ('\n ' )
88
- sys .stdout .write (formatter .format_help ())
86
+ if args .revision == '' :
87
+ try :
88
+ pi_info ().pprint (color = args .color )
89
+ except IOError :
90
+ raise IOError ('This device is not a Raspberry Pi' )
91
+ else :
92
+ pi_info (args .revision ).pprint (color = args .color )
93
+ formatter = self .parser ._get_formatter ()
94
+ formatter .add_text (
95
+ "For further information, please refer to "
96
+ "https://pinout.xyz/"
97
+ )
98
+ sys .stdout .write ('\n ' )
99
+ sys .stdout .write (formatter .format_help ())
89
100
90
101
91
102
main = PinoutTool ()
0 commit comments