can-go
can-go copied to clipboard
feat: allow `generate` command to generate a single DBC file
This commit allows a user to run
cantool generate INPUT OUTPUT-DIRECTORY
where INPUT is either a path to a DBC file. Previously it was only possible to provide INPUT as a directory containing DBC files.
N.B. When INPUT is a directory containing DBC files the generated files are created in OUTPUT-DIRECTORY relative to where they are found in INPUT.
As an example, given the following directory structure:
dbc/
powertrain/pt.dbc
steering/steer.dbc
brake/brake.dbc
A cantool generate dbc/ gen/go
call will generate the following
structure:
gen/go/
powertrain/pt.dbc.go
steering/steer.dbc.go
brake/brake.dbc.go
However, when INPUT is a single DBC file it is generated directly in OUTPUT-DIRECTORY with its basename as the stem.
cantool generate dbc/steering/steer.dbc gen/go/steering
will
therefore generate the gen/go/steering/steer.dbc.go.
Inspired by #292 (thanks @bertaveira!)