Skip to content

Commit

Permalink
resource.py refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 15, 2024
1 parent d28d8cc commit c6f0c93
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": ["boards", "-f"],
"args": ["boards", "-l"],
"console": "internalConsole",
"justMyCode": true,
//-- Change to the folder with the example to test
"cwd": "${workspaceFolder}/test-examples/Alhambra-II/ledon"
"cwd": "${workspaceFolder}/test-examples/Alhambra-II/temp-ledon"
},
{
"name": "Apio config",
Expand Down
29 changes: 21 additions & 8 deletions apio/commands/boards.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
# -- This file is part of the Apio project
# -- (C) 2016-2019 FPGAwars
# -- Author Jesús Arroyo
# -- (C) 2016-2024 FPGAwars
# -- Authors
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO BOARDS command"""

Expand All @@ -10,27 +12,38 @@
from apio.resources import Resources
from apio import util

# ------------------
# -- CONSTANTS
# ------------------
CMD = "boards" # -- Comand name
LIST = "list" # -- Option
FPGA = "fpga" # -- Option

@click.command("boards", context_settings=util.context_settings())

@click.command(CMD, context_settings=util.context_settings())
@click.pass_context
@click.option(
"-l",
"--list",
"list_boards",
f"--{LIST}",
is_flag=True,
help="List all supported FPGA boards.",
)
@click.option(
"-f", "--fpga", is_flag=True, help="List all supported FPGA chips."
"-f", f"--{FPGA}", is_flag=True, help="List all supported FPGA chips."
)
def cli(ctx, list_boards: bool, fpga: bool):
def cli(ctx, **kwargs):
# def cli(ctx, list_boards: bool, fpga: bool):
"""Manage FPGA boards."""

# -- Extract the arguments
_list = kwargs[LIST] # -- bool
fpga = kwargs[FPGA] # -- bool

# -- Access to the apio resources
resources = Resources()

# -- Option 1: List boards
if list_boards:
if _list:
resources.list_boards()

# -- Option 2: List fpgas
Expand Down

0 comments on commit c6f0c93

Please sign in to comment.