Skip to content

Commit 2f43cef

Browse files
Merge pull request #55 from asadafasab/master
Create new question #47 and close pull #55
2 parents 0b9e6b2 + 0e4f2db commit 2f43cef

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
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+
1926
ARGV = PARSER.parse_args()
2027

2128
search_flag = Search(ARGV)

src/arguments/search.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env python
22
import argparse
3+
import webbrowser
34
from termcolor import colored
45
from .utility import Utility, SearchError
56
import sys as sys
67

8+
79
class 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+
1620
class 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)

0 commit comments

Comments
 (0)