Skip to content

Commit

Permalink
apio init: --top-module admits the --project-dir param
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Feb 20, 2024
1 parent d8afea2 commit 0616e06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apio/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ def cli(ctx, board, top_module, scons, project_dir, sayyes):
Project().create_ini(board, top_module, project_dir, sayyes)
elif top_module:
print("INIT TOP-MODULE!!")
Project().update_ini(top_module)
Project().update_ini(top_module, project_dir)
else:
click.secho(ctx.get_help())
10 changes: 6 additions & 4 deletions apio/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ def create_ini(self, board, top_module, project_dir="", sayyes=False):
# -- Create the apio.ini from scratch
self._create_ini_file(board, top_module, ini_path, PROJECT_FILENAME)

def update_ini(self, top_module):
def update_ini(self, top_module, project_dir):
"""Update the current init file with the given top-module"""

project_dir = util.check_dir(project_dir)

# -- Build the filename
ini_path = PROJECT_FILENAME
ini_path = str(Path(project_dir) / PROJECT_FILENAME)

# -- Check if the apio.ini file exists
if not isfile(ini_path):
Expand All @@ -122,14 +124,14 @@ def update_ini(self, top_module):

# -- Read the current apio.ini file
config = configparser.ConfigParser()
config.read(PROJECT_FILENAME)
config.read(ini_path)

# -- Set the new top-mddule
self.top_module = top_module
config.set("env", "top-module", top_module)

# -- Write the apio ini file
with open(PROJECT_FILENAME, "w", encoding="utf-8") as inifile:
with open(ini_path, "w", encoding="utf-8") as inifile:
config.write(inifile)

click.secho(
Expand Down

0 comments on commit 0616e06

Please sign in to comment.