@@ -17,6 +17,8 @@ def __init__(self):
1717 # Instance specific variables
1818 self .browserFlag = False
1919 self .fileFlag = False
20+ self .randomFlag = False
21+ self .contentFlag = False
2022
2123 self ._question_id : int = None
2224 self ._title_slug : str = None
@@ -107,8 +109,7 @@ def _execute(self, args):
107109 question_content = QuestionContent (problem .titleSlug )
108110 console .print (question_info_table )
109111 console .print (question_content )
110-
111- else :
112+ elif getattr (args , 'id' ) != 0 :
112113 try :
113114 with Loader ('Fetching problem info...' , '' ):
114115 self .data = self .leet_api .get_request (self .API_URL )
@@ -124,6 +125,8 @@ def _execute(self, args):
124125 console .print (f"{ e .__class__ .__name__ } : { e } " , style = ALERT )
125126 if self .fileFlag :
126127 self .create_submission_file (self .title_slug )
128+ else :
129+ console .print ("Invalid ID has been provided. Please try again." , style = ALERT )
127130
128131 @classmethod
129132 def create_submission_file (cls , title_slug : str = None ) -> None :
@@ -133,9 +136,11 @@ def create_submission_file(cls, title_slug: str = None) -> None:
133136 Args:
134137 title_slug (str): The title slug of the problem.
135138 """
139+ watermark_info = '# This file was created by pyleetcode-cli software.\n # Do NOT modify the name of the file.\n \n '
136140 question = GetQuestionDetail (title_slug )
137141 file_name = f"{ question .question_id } .{ question .title_slug } .py"
138142 with open (file_name , 'w' ) as file :
143+ file .write (watermark_info )
139144 file .write (question .code_snippet )
140145 console .print (f"File '{ file_name } ' has been created." )
141146
@@ -146,12 +151,15 @@ def show(self):
146151 link = self .config .host + f'/problems/{ self .title_slug } /'
147152 console .print (f'Link to the problem: { link } ' )
148153 self .open_in_browser (link )
149- else :
154+ elif self . contentFlag :
150155 question_info_table = QuestionInfoTable (self .title_slug )
151156 console .print (question_info_table )
152157 question_content = QuestionContent (self .title_slug )
153158 console .print (question_content )
154-
159+ else :
160+ question_info_table = QuestionInfoTable (self .title_slug )
161+ console .print (question_info_table )
162+
155163 def __parse_args (self , args ) -> None :
156164 """ Parses the arguments passed to the query.
157165
@@ -161,6 +169,10 @@ def __parse_args(self, args) -> None:
161169 self .browserFlag = True
162170 if getattr (args , 'file' ):
163171 self .fileFlag = True
172+ if getattr (args , 'random' ):
173+ self .randomFlag = True
174+ if getattr (args , 'contents' ):
175+ self .contentFlag = True
164176
165177 @property
166178 def data (self ):
0 commit comments