I... think it's done? That was suspiciously easy.

This commit is contained in:
David Given
2019-07-02 23:20:47 +02:00
parent a1c207cb8f
commit f7af8bb99b
23 changed files with 38 additions and 23 deletions

View File

@@ -49,10 +49,12 @@ void FlagGroup::parseFlags(int argc, const char* argv[])
for (Flag* flag : group->_flags)
{
const auto& name = flag->name();
if (flags_by_name.find(name) != flags_by_name.end())
Error() << "two flags use the name '" << name << "'";
flags_by_name[name] = flag;
for (const auto& name : flag->names())
{
if (flags_by_name.find(name) != flags_by_name.end())
Error() << "two flags use the name '" << name << "'";
flags_by_name[name] = flag;
}
all_flags.push_back(flag);
}
@@ -60,6 +62,7 @@ void FlagGroup::parseFlags(int argc, const char* argv[])
group->_initialised = true;
};
recurse(this);
recurse(&helpGroup);
/* Now actually parse them. */

View File

@@ -1,6 +1,10 @@
#ifndef FLUXSOURCE_H
#define FLUXSOURCE_H
#include "flags.h"
extern FlagGroup hardwareFluxSourceFlags;
class Fluxmap;
class DataSpec;

View File

@@ -16,7 +16,7 @@
#include "track.h"
#include "fmt/format.h"
FlagGroup readerFlags;
FlagGroup readerFlags { &hardwareFluxSourceFlags, &fluxmapReaderFlags };
static DataSpecFlag source(
{ "--source", "-s" },

View File

@@ -1,11 +1,15 @@
#ifndef READER_H
#define READER_H
#include "flags.h"
class Fluxmap;
class FluxSource;
class AbstractDecoder;
class Track;
extern FlagGroup readerFlags;
extern void setReaderDefaultSource(const std::string& source);
extern void setReaderRevolutions(int revolutions);

View File

@@ -10,7 +10,7 @@
#include "fluxsink.h"
#include "fmt/format.h"
FlagGroup writerFlags;
FlagGroup writerFlags { &hardwareFluxSourceFlags };
static DataSpecFlag dest(
{ "--dest", "-d" },

View File

@@ -1,6 +1,10 @@
#ifndef WRITER_H
#define WRITER_H
#include "flags.h"
extern FlagGroup writerFlags;
class Fluxmap;
extern void setWriterDefaultDest(const std::string& dest);

View File

@@ -10,7 +10,7 @@
#include "ibm.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "aeslanier.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "ibm.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "ibm.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "fb100.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "ibm.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fmt/format.h>
#include <fstream>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -10,7 +10,7 @@
#include "zilogmcz.h"
#include <fmt/format.h>
FlagGroup flags;
FlagGroup flags { &readerFlags };
static StringFlag outputFilename(
{ "--output", "-o" },

View File

@@ -11,7 +11,7 @@
#include <fstream>
#include <ctype.h>
FlagGroup flags;
FlagGroup flags { &writerFlags };
static StringFlag inputFilename(
{ "--input", "-i" },

View File

@@ -10,7 +10,7 @@
#include <fstream>
#include <ctype.h>
FlagGroup flags;
FlagGroup flags { &writerFlags };
int main(int argc, const char* argv[])
{

View File

@@ -8,7 +8,7 @@
#include <fstream>
#include <ctype.h>
FlagGroup flags;
FlagGroup flags { &writerFlags };
static DoubleFlag interval(
{ "--interval" },