Skip to content

Commit e5cce0f

Browse files
author
Vivek Dagar
committed
decoupled shell and file
1 parent 420ce50 commit e5cce0f

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='xbasic',
5-
version='1.2.1',
5+
version='1.2.2',
66
packages=find_packages(),
77
install_requires=[
88
'click~=8.1.7',

xbasic/main.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@click.group()
99
def cli():
10-
"""XBasic CLI tool."""
10+
"""XBasic Shell"""
1111
pass
1212

1313

@@ -33,26 +33,30 @@ def entry_shell():
3333

3434

3535
@cli.command()
36-
@click.option('-f', type=click.Path(exists=True), default=None, help='Specify a file to execute within the shell.')
37-
def shell(f):
38-
"""Start an interactive shell or execute a file within the shell."""
36+
def shell():
37+
"""Start an interactive shell"""
3938
print_intro()
40-
if f:
41-
if not f.endswith('.bsx'):
42-
click.echo("Error: File must end with '.bsx'.")
43-
return
44-
result, error = run('<stdin>', f'RUN("{f}")')
45-
if error:
46-
print(error.as_string())
47-
elif result:
48-
print("The process returned ", result)
49-
else:
50-
entry_shell()
39+
entry_shell()
40+
41+
42+
@cli.command()
43+
@click.option('-f', type=click.Path(exists=True), required=True, default=None,
44+
help='Specify a file to execute within the shell.')
45+
def file(f):
46+
"""Execute a file within the shell"""
47+
if not f.endswith('.bsx'):
48+
click.echo("Error: File must end with '.bsx'.")
49+
return
50+
result, error = run('<stdin>', f'RUN("{f}")')
51+
if error:
52+
print(error.as_string())
53+
elif result:
54+
print("The process returned ", result)
5155

5256

5357
def print_intro():
5458
"""Print introductory information."""
55-
version = "1.2.1"
59+
version = "1.2.2"
5660
current_date_time = datetime.datetime.now().strftime("%b %d %Y, %H:%M:%S")
5761
os_name = platform.system()
5862
intro = f"XBasic {version} ({current_date_time}) on {os_name.lower()}"

0 commit comments

Comments
 (0)