Skip to content

Commit

Permalink
Merge pull request #418 from zapta/develop
Browse files Browse the repository at this point in the history
Now printing an info message when a deprecated flag is used.
  • Loading branch information
Obijuan authored Sep 22, 2024
2 parents 31b9ccb + d487232 commit e5e3c96
Show file tree
Hide file tree
Showing 26 changed files with 179 additions and 90 deletions.
14 changes: 12 additions & 2 deletions apio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ def select_commands_help(command_lines, command_names):
return result


def context_settings():
"""Return a common Click command settings that adds
the alias -h to --help. This applies also to all the sub
commands such as apio build.
"""
# Per https://click.palletsprojects.com/en/8.1.x/documentation/
# #help-parameter-customization
return {"help_option_names": ["-h", "--help"]}


# ---------------------------
# -- Top click command node.
# ---------------------------
Expand All @@ -118,7 +128,7 @@ def select_commands_help(command_lines, command_names):
Apio commands are typically invoked in the root directory of the FPGA
project where the project configuration file apio.ini and the project
source files are stored. For help on specific commands use the -h
flag (e.g. apio build -h).
flag (e.g. 'apio build -h').
For more information on the apio project see
https://github.com/FPGAwars/apio/wiki/Apio
Expand All @@ -129,7 +139,7 @@ def select_commands_help(command_lines, command_names):
cls=ApioCLI,
help=HELP,
invoke_without_command=True,
context_settings=util.context_settings(),
context_settings=context_settings(),
)
@click.pass_context
@click.version_option()
Expand Down
5 changes: 3 additions & 2 deletions apio/commands/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO BOARDS command"""
"""Implementation of 'apio boards' command"""

from pathlib import Path
import click
Expand All @@ -23,6 +23,7 @@
"--fpga",
is_flag=True,
help="List supported FPGA chips.",
cls=util.ApioOption,
)


Expand Down Expand Up @@ -50,7 +51,7 @@
"boards",
short_help="List supported boards and FPGAs.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.project_dir_option
Expand Down
12 changes: 4 additions & 8 deletions apio/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO BUILD command"""
"""Implementation of 'apio build' command"""

from pathlib import Path
import click
Expand All @@ -29,10 +29,6 @@
Examples:
apio build
apio build -v
[Note] The flags marked with (deprecated) are not recomanded.
Instead, use an apio.ini project config file and if neaded, add
to the project custom boards.json and fpga.json files.
"""


Expand All @@ -42,15 +38,15 @@
"build",
short_help="Synthesize the bitstream.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.project_dir_option
@options.verbose_option
@options.verbose_yosys_option
@options.verbose_pnr_option
@options.top_module_option_gen()
@options.board_option_gen()
@options.top_module_option_gen(deprecated=True)
@options.board_option_gen(deprecated=True)
@options.fpga_option
@options.size_option
@options.type_option
Expand Down
10 changes: 3 additions & 7 deletions apio/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO CLEAN command"""
"""Implementation of 'apio clean' command"""

from pathlib import Path
import click
Expand All @@ -28,10 +28,6 @@
Example:
apio clean
[Note] The flags marked with (deprecated) are not recomanded.
Instead, use an apio.ini project config file and if neaded, add
to the project custom boards.json and fpga.json files.
[Hint] If you are using a git repository, add a .gitignore file with
the temporary apio file names.
"""
Expand All @@ -41,12 +37,12 @@
"clean",
short_help="Clean the apio generated files.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.project_dir_option
@options.verbose_option
@options.board_option_gen()
@options.board_option_gen(deprecated=True)
def cli(
ctx: Context,
# Options
Expand Down
4 changes: 2 additions & 2 deletions apio/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO CREATE command"""
"""Implementation of 'apio create' command"""

from pathlib import Path
import click
Expand Down Expand Up @@ -50,7 +50,7 @@
"create",
short_help="Create an apio.ini project file.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.board_option_gen(help="Set the board.", required=True)
Expand Down
8 changes: 6 additions & 2 deletions apio/commands/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO DRIVERS command"""
"""Implementation of 'apio drivers' command"""

import click
from click.core import Context
Expand All @@ -20,27 +20,31 @@
"--ftdi-enable",
is_flag=True,
help="Enable FTDI drivers.",
cls=util.ApioOption,
)

ftdi_disable_option = click.option(
"ftdi_disable", # Var name.
"--ftdi-disable",
is_flag=True,
help="Disable FTDI drivers.",
cls=util.ApioOption,
)

serial_enable_option = click.option(
"serial_enable", # Var name.
"--serial-enable",
is_flag=True,
help="Enable Serial drivers.",
cls=util.ApioOption,
)

serial_disable_option = click.option(
"serial_disable", # Var name.
"--serial-disable",
is_flag=True,
help="Disable Serial drivers.",
cls=util.ApioOption,
)


Expand Down Expand Up @@ -68,7 +72,7 @@
"drivers",
short_help="Manage the operating system drivers.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@frdi_enable_option
Expand Down
6 changes: 4 additions & 2 deletions apio/commands/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO EXAMPLES command"""
"""Implementation of 'apio examples' command"""

from pathlib import Path
import click
Expand All @@ -24,6 +24,7 @@
type=str,
metavar="name",
help="Copy the selected example directory.",
cls=util.ApioOption,
)

files_option = click.option(
Expand All @@ -33,6 +34,7 @@
type=str,
metavar="name",
help="Copy the selected example files.",
cls=util.ApioOption,
)


Expand All @@ -58,7 +60,7 @@
"examples",
short_help="List and fetch apio examples.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.list_option_gen(help="List all available examples.")
Expand Down
4 changes: 2 additions & 2 deletions apio/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO GRAPH command"""
"""Implementation of 'apio graph' command"""

from pathlib import Path
import click
Expand Down Expand Up @@ -42,7 +42,7 @@
"graph",
short_help="Generate a visual graph of the code.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.project_dir_option
Expand Down
7 changes: 4 additions & 3 deletions apio/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO INIT command"""
"""Implementation of 'apio init' command"""

# pylint: disable=fixme
# TODO: After migrating IceStudio to the create/modify commands, delete
Expand All @@ -28,6 +28,7 @@
"--scons",
is_flag=True,
help="(Advanced, for developers) Create default SConstruct file.",
cls=util.ApioOption,
)


Expand All @@ -44,9 +45,9 @@
# pylint: disable=R0913
@click.command(
"init",
short_help="(deprecated) Manage apio projects.",
short_help="[DEPRECATED] Manage apio projects.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.board_option_gen(help="Create init file with the selected board.")
Expand Down
4 changes: 2 additions & 2 deletions apio/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO INSTALL command"""
"""Implementation of 'apio install' command"""

from pathlib import Path
from typing import Tuple
Expand Down Expand Up @@ -60,7 +60,7 @@ def install_packages(
"install",
short_help="Install apio packages.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@click.argument("packages", nargs=-1, required=False)
Expand Down
11 changes: 6 additions & 5 deletions apio/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO LINT command"""
"""Implementation of 'apio lint' command"""

from pathlib import Path
import click
Expand All @@ -23,6 +23,7 @@
"--nostyle",
is_flag=True,
help="Disable all style warnings.",
cls=util.ApioOption,
)


Expand All @@ -32,6 +33,7 @@
type=str,
metavar="nowarn",
help="Disable specific warning(s).",
cls=util.ApioOption,
)

warn_option = click.option(
Expand All @@ -40,6 +42,7 @@
type=str,
metavar="warn",
help="Enable specific warning(s).",
cls=util.ApioOption,
)


Expand All @@ -57,8 +60,6 @@
\b
Examples:
apio lint
[Note] The flags marked with (deprecated) are not recomanded for use.
"""


Expand All @@ -68,7 +69,7 @@
"lint",
short_help="Lint the verilog code.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.all_option_gen(
Expand All @@ -78,7 +79,7 @@
@nowarn_option
@warn_option
@options.project_dir_option
@options.top_module_option_gen()
@options.top_module_option_gen(deprecated=True)
def cli(
ctx: Context,
# Options
Expand Down
4 changes: 2 additions & 2 deletions apio/commands/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# -- * Jesús Arroyo (2016-2019)
# -- * Juan Gonzalez (obijuan) (2019-2024)
# -- Licence GPLv2
"""Main implementation of APIO MODIFY command"""
"""Implementation of 'apio modify' command"""

from pathlib import Path
import click
Expand Down Expand Up @@ -42,7 +42,7 @@
"modify",
short_help="Modify the apio.ini project file.",
help=HELP,
context_settings=util.context_settings(),
cls=util.ApioCommand,
)
@click.pass_context
@options.board_option_gen(help="Set the board.")
Expand Down
Loading

0 comments on commit e5e3c96

Please sign in to comment.