File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1616 version = f"Dynamic-CLI version { version } " ,
1717 action = 'version' )
1818
19+ PARSER .add_argument ("-n" ,
20+ "--new" ,
21+ help = "Opens browser to create new Stack Overflow question." ,
22+ const = True ,
23+ metavar = "title (optional)" ,
24+ nargs = "?" )
25+
1926ARGV = PARSER .parse_args ()
2027
2128search_flag = Search (ARGV )
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22import argparse
3+ import webbrowser
34from termcolor import colored
45from .utility import Utility , SearchError
56import sys as sys
67
8+
79class Prompt ():
810 def __init__ (self , message ):
911 self .message = message
@@ -13,6 +15,8 @@ def prompt(self):
1315 data = input ()
1416
1517 return str (data )
18+
19+
1620class Search ():
1721 def __init__ (self , arguments ):
1822 self .arguments = arguments
@@ -25,7 +29,7 @@ def search_args(self):
2529
2630 # ask quesiton
2731 for each_query in queries :
28- # Be careful if there are
32+ # Be careful if there are
2933 # KeyBpard Interupts or EOErrors
3034 try :
3135 prompt = Prompt (str (each_query )).prompt ()
@@ -43,3 +47,10 @@ def search_args(self):
4347 "Please try reddit" )
4448 else :
4549 self .utility_object .get_ans (questions )
50+
51+ elif self .arguments .new :
52+ url = "https://stackoverflow.com/questions/ask"
53+ if type (self .arguments .new ) == str :
54+ webbrowser .open (f"{ url } ?title={ self .arguments .new } " )
55+ else :
56+ webbrowser .open (url )
You can’t perform that action at this time.
0 commit comments