Skip to content

Commit

Permalink
prefs: support --lib flag
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Jun 6, 2024
1 parent fc5b9ef commit 4fb968a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bsc/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
class Prefs:
def __init__(self):
self.input = ""
self.is_library = False

def parse_args(self):
parser = argparse.ArgumentParser(
prog = 'bsc', description = 'The BlueScript compiler'
)
parser.add_argument('input', help = "the input file")
parser.add_argument('--lib', action='store_true', help='specifies whether the entry is a library or not')
args = parser.parse_args()

self.is_library = args.lib

# check input file
self.input = args.input
if os.path.exists(self.input):
if not os.path.isfile(self.input):
utils.error(f"`{self.input}` is a directory, expected a file")
else:
if os.path.isdir(self.input):
input_file = "lib.bs" if self.is_library else "main.bs"
self.input = os.path.join(self.input, input_file)

if not os.path.exists(self.input):
utils.error(f"file `{self.input}` does not exist")

0 comments on commit 4fb968a

Please sign in to comment.