Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
arguments.cpp File Reference

A command's options read as Python's argparse read them. More...

#include "arguments.h"
#include "common.h"
#include <QtCore/QJsonValue>

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

qsizetype Sonde::Cli::anonymous_namespace{arguments.cpp}::textWidth ()
 How wide argparse makes its text: $COLUMNS (else 80), less 2.
QStringList Sonde::Cli::anonymous_namespace{arguments.cpp}::usageLines (const QStringList &parts, const QString &indent, const QString &prefix)
 parts in lines of at most textWidth(), each line after the first starting with indent; the first starts after prefix, which isn't included.
QString Sonde::Cli::anonymous_namespace{arguments.cpp}::usage (const ArgumentSpec &spec)
 The usage of spec, wrapped as argparse wraps it.
QString Sonde::Cli::anonymous_namespace{arguments.cpp}::matchFlag (const ArgumentSpec &spec, const QString &arg)
 The flag of spec that arg names, in full or abbreviated, or an empty string for none.
const ValueOption * Sonde::Cli::anonymous_namespace{arguments.cpp}::valueOption (const ArgumentSpec &spec, const QString &name)
 The option of spec named name that takes a value, or nothing.
bool Sonde::Cli::anonymous_namespace{arguments.cpp}::isNegativeNumber (const QString &arg)
 Whether arg looks like a negative number, which argparse takes as a value.
const ValueOption * Sonde::Cli::anonymous_namespace{arguments.cpp}::attachedShortOption (const ArgumentSpec &spec, const QString &arg)
 The option of spec with its value attached to arg ("-n5"), or nothing.
QString Sonde::Cli::anonymous_namespace{arguments.cpp}::checkedValue (const ArgumentSpec &spec, const ValueOption &option, const QString &value)
 value checked as option's: an integer, if it must be one.
bool Sonde::Cli::anonymous_namespace{arguments.cpp}::takeOption (const ArgumentSpec &spec, const QStringList &args, qsizetype &i, Arguments &out)
 Reads the option at i in args into out, and its value, which may be the next argument (then i moves to it).
void Sonde::Cli::usageError (const ArgumentSpec &spec, const QString &message)
 Prints the usage of spec and message, and exits with 2, as argparse's error() does.
QString Sonde::Cli::helpText (const ArgumentSpec &spec)
 The help -h prints for spec.
Arguments Sonde::Cli::parseArguments (const ArgumentSpec &spec, const QStringList &args)
 Reads args as spec says.

Detailed Description

A command's options read as Python's argparse read them.

Function Documentation

◆ parseArguments()

Arguments Sonde::Cli::parseArguments ( const ArgumentSpec & spec,
const QStringList & args )

Reads args as spec says.

With -h or --help, prints the help and exits with 0; with an argument it doesn't know, prints the usage and an error and exits with 2.