Skip to content

Commit

Permalink
flet create command to show verbose output (#2544)
Browse files Browse the repository at this point in the history
* `flet create` command to show verbose output

* Exclamation!

* Fixed: flet build macos does not yield output if --product option is provided with a value different from project name

Fix #2525
  • Loading branch information
FeodorFitsner committed Feb 4, 2024
1 parent 21f1026 commit e0178ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 5 additions & 3 deletions sdk/python/packages/flet/src/flet/cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, parser: argparse.ArgumentParser) -> None:
"macos": {
"build_command": "macos",
"status_text": "macOS bundle",
"output": "build/macos/Build/Products/Release/{project_name}.app",
"output": "build/macos/Build/Products/Release/{product_name}.app",
"dist": "macos",
"can_be_run_on": ["Darwin"],
},
Expand Down Expand Up @@ -319,15 +319,16 @@ def handle(self, options: argparse.Namespace) -> None:
options.project_name if options.project_name else python_app_path.name
).replace("-", "_")

product_name = options.product_name if options.product_name else project_name

template_data["project_name"] = project_name

if options.description is not None:
template_data["description"] = options.description

template_data["sep"] = os.sep
template_data["python_module_name"] = python_module_name
if options.product_name:
template_data["product_name"] = options.product_name
template_data["product_name"] = product_name
if options.org_name:
template_data["org_name"] = options.org_name
if options.company_name:
Expand Down Expand Up @@ -714,6 +715,7 @@ def fallback_image(yaml_path: str, images: list):
str(self.flutter_dir.joinpath(self.platforms[target_platform]["output"]))
.replace("{arch}", arch)
.replace("{project_name}", project_name)
.replace("{product_name}", product_name)
)
build_output_glob = os.path.basename(build_output_dir)
build_output_dir = os.path.dirname(build_output_dir)
Expand Down
24 changes: 20 additions & 4 deletions sdk/python/packages/flet/src/flet/cli/commands/create.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import os
from pathlib import Path

import flet.version
Expand Down Expand Up @@ -43,6 +44,8 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> None:
def handle(self, options: argparse.Namespace) -> None:
from cookiecutter.main import cookiecutter

self.verbose = options.verbose

template_data = {"template_name": options.template}

template_ref = None
Expand Down Expand Up @@ -71,8 +74,21 @@ def handle(self, options: argparse.Namespace) -> None:
extra_context=template_data,
)

print("[spring_green3]Done![/spring_green3]\n")

if self.verbose > 0:
print(f"[cyan]Files created at[/cyan] {out_dir}:\n")
for root, dirs, files in os.walk(out_dir):
for file in files:
rel_path = os.path.relpath(os.path.join(root, file), out_dir)
print(rel_path)
print("")

# print next steps
print("[spring_green3]Done.[/spring_green3] Now run:\n")
if options.output_directory != ".":
print(f"[cyan]cd[/cyan] [white]{out_dir.name}[/white]")
print("[cyan]flet run[/cyan]\n")
print("[cyan]Run the app:[/cyan]\n")
app_dir = (
os.path.relpath(out_dir, os.getcwd())
if options.output_directory != "."
else ""
)
print(f"flet run {app_dir}\n")

0 comments on commit e0178ad

Please sign in to comment.