Skip to content

Commit

Permalink
utilize standard pathlib library for path manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
DeleMike committed Jul 4, 2023
1 parent 807be47 commit 2a63485
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.sh
@@ -1,3 +1,3 @@
#!/bin/sh

python3 starfyre --dev=True --path="test-application/" && python -m starfyre --build=True --path="test-application/"
python3 starfyre --build --path="test-application"
38 changes: 27 additions & 11 deletions starfyre/__main__.py
Expand Up @@ -41,20 +41,36 @@ def create_main_file(path):


@click.command()
@click.option("--path", default=".", help="Path to the project")
@click.option("--dev", default=False, help="Start the compilation and generate the build package.")
@click.option("--build", default=False, help="Start the build package")
def main(path, dev, build):
if dev:
path_ = path + "/__init__.py"
# get absolute path
path = os.path.abspath(path_)
compile(path)
create_main_file(os.path.dirname(path))
@click.option("--path", help="Path to the project")
@click.option("--build", is_flag=True, help="Compile and build package")
def main(path, build):
"""
Command-line interface to compile and build a Starfyre project.
Args:
path (str): Path to the project directory.\n
build (bool): Whether to start the build package.
"""
if not path:
click.echo(
"Error: Please provide a valid path using the --path flag.\nUse --help for more details")
return

# Convert path to absolute path
absolute_path = Path(path).resolve()

if build:
# Compile and build project
init_file_path = absolute_path / "__init__.py"
compile(init_file_path.resolve())
create_main_file(str(absolute_path))

# Start/run project
build_dir = absolute_path / "build"
subprocess.run(
[sys.executable, "-m", "build"],
cwd=path,
cwd=build_dir.resolve(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
Expand Down

0 comments on commit 2a63485

Please sign in to comment.