Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for userdb file in CLI #347

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cli/encodecallsigndb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ int encodeCallsignDB(QCommandLineParser &parser, QCoreApplication &app) {
parser.showHelp(-1);

UserDatabase userdb;
if (0 == userdb.count()) {
if (parser.isSet("database")) {
if (! userdb.load(parser.value("database"))) {
logError() << "Cannot load user-db from '" << parser.value("database") << "'.";
return -1;
}
} else if (0 == userdb.count()) {
logInfo() << "Downloading call-sign DB...";
// Wait for download to finish
QEventLoop loop;
Expand Down
6 changes: 6 additions & 0 deletions cli/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ int main(int argc, char *argv[])
"maximum number of callsigns to encode."),
QCoreApplication::translate("main", "N")
});
parser.addOption({
{"B","database"},
QCoreApplication::translate("main", "Specifies the user DB json file when "
"writing the callsign db."),
"FILENAME"
});
parser.addOption(QCommandLineOption(
"init-codeplug",
QCoreApplication::translate(
Expand Down
8 changes: 7 additions & 1 deletion cli/writecallsigndb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

int writeCallsignDB(QCommandLineParser &parser, QCoreApplication &app) {
UserDatabase userdb;
if (0 == userdb.count()) {

if (parser.isSet("database")) {
if (! userdb.load(parser.value("database"))) {
logError() << "Cannot load user-db from '" << parser.value("database") << "'.";
return -1;
}
} else if (0 == userdb.count()) {
logInfo() << "Downloading call-sign DB...";
// Wait for download to finish
QEventLoop loop;
Expand Down
8 changes: 8 additions & 0 deletions doc/dmrconf.in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-B</option> or <option>--database=</option>JSON_FILE</term>
<listitem>
<para>
Specifies the call-sign database to use for writing a user-db to the device.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--init-codeplug</option></term>
<listitem>
Expand Down
18 changes: 18 additions & 0 deletions doc/manual/cli/callsign.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@
(both prefixes for Germany).
</para>

<section>
<info><title>Specifying own databases</title></info>
<para>
With version 0.11.3, it is possible, to specify a user-crafted JSON database. Then, this
file will be used for selecting the call signs for writing the call-sign DB.
</para>

<informalexample>
<programlisting><![CDATA[dmrconf write-db --id=262 --limit=10000 --database=my_db.json]]></programlisting>
</informalexample>

<para>
Here, up to 10000 call signs are written from the <filename>my_db.json</filename> JSON file
starting with those IDs closest to the prefix 262. Specifying a user-curated call-sign DB, simply
replaces the public one and thus all methods described above still work.
</para>
</section>

<section xml:id="cmdEncodeDB">
<info><title>Encoding a call-sign DB</title></info>

Expand Down
10 changes: 9 additions & 1 deletion doc/manual/cli/dmrconf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<refentrytitle>dmrconf</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="source">dmrconf</refmiscinfo>
<refmiscinfo class="version">0.10.2</refmiscinfo>
<refmiscinfo class="version">0.11.3</refmiscinfo>
<refmiscinfo class="manual">User Commands</refmiscinfo>
</refmeta>

Expand Down Expand Up @@ -242,6 +242,14 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-B</option> or <option>--database=</option>JSON_FILE</term>
<listitem>
<para>
Specifies the call-sign database to use for writing a user-db to the device.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--init-codeplug</option></term>
<listitem>
Expand Down