wxMaxima
Loading...
Searching...
No Matches
CommandLineOptions.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2026 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// SPDX-License-Identifier: GPL-2.0+
20
38#ifndef WXM_COMMANDLINEOPTIONS_H
39#define WXM_COMMANDLINEOPTIONS_H
40
41#include <array>
42#include <string_view>
43
44namespace wxm::cmdline {
45
47enum class Kind { Switch, Option };
48
50enum class Complete {
51 Nothing,
52 Openable,
53 AnyFile
54};
55
57struct Option {
58 Kind kind;
60 std::string_view shortName;
62 std::string_view longName;
64 std::string_view description;
66 std::string_view valueName = {};
68 Complete complete = Complete::Nothing;
70 bool isHelp = false;
71};
72
74inline constexpr std::array Options{
75 Option{Kind::Switch, "v", "version", "Output the version info."},
76 Option{Kind::Switch, "h", "help", "Show this help message.", {},
77 Complete::Nothing, true},
78 Option{Kind::Option, "o", "open", "Open a file.", "file",
79 Complete::Openable},
80 Option{Kind::Switch, "e", "eval", "Evaluate the file after opening it."},
81 Option{Kind::Switch, "d", "diff",
82 "Compare 2 or 3 files side-by-side using the Diff viewer."},
83 Option{Kind::Switch, "", "single_process",
84 "Open all worksheets from within the same process."},
85 Option{Kind::Switch, "", "single_thread",
86 "Run all background tasks from within the main thread."},
87 Option{Kind::Switch, "b", "batch",
88 "Run the file and exit afterwards. Halts on questions and stops on "
89 "errors."},
90 Option{Kind::Switch, "", "logtostderr",
91 "Log all \"debug messages\" sidebar messages to stderr, too."},
92 Option{Kind::Switch, "", "debug", "Enable costly debug checks."},
93 Option{Kind::Switch, "", "pipe", "Pipe messages from Maxima to stderr."},
94 Option{Kind::Switch, "", "exit-on-error",
95 "Close the program on any Maxima error."},
96 Option{Kind::Option, "", "language",
97 "Use this language for the user interface instead of the configured "
98 "one, for example de or pt_BR. The setting is not saved.",
99 "lang"},
100 Option{Kind::Option, "f", "ini",
101 "Allows specifying a file to store the configuration in.", "file",
102 Complete::AnyFile},
103 Option{Kind::Option, "u", "use-version", "Use Maxima version <str>.",
104 "str"},
105 Option{Kind::Option, "l", "lisp",
106 "Use a Maxima compiled with lisp compiler <str>.", "str"},
107 Option{Kind::Option, "X", "extra-args",
108 "Allows specifying extra Maxima arguments.", "args"},
109 Option{Kind::Option, "m", "maxima",
110 "Allows specifying the location of the Maxima binary.", "file",
111 Complete::AnyFile},
112 Option{Kind::Switch, "", "enableipc",
113 "Lets Maxima control wxMaxima via interprocess communications. Use "
114 "this option with care."},
115 Option{Kind::Option, "", "screenshot",
116 "Evaluate the file, save a screenshot as <file> once Maxima is idle "
117 "and exit. What is shown is read from the [Screenshot] group of the "
118 "configuration (see --ini). For the manual's screenshots; needs an "
119 "X11 display.",
120 "file", Complete::AnyFile},
121 Option{Kind::Option, "", "wxmathml-lisp",
122 "Location of wxMathML.lisp (if not the built-in should be used, "
123 "mainly for developers).",
124 "file", Complete::AnyFile},
125};
126
128inline constexpr std::string_view ParamDescription = "input file";
129
137inline constexpr std::array<std::string_view, 10> OpenableExtensions{
138 "wxm", "wxmx", "zip", "mac", "out", "xml", "dem", "lisp", "lsp", "mc"};
139
140} // namespace wxm::cmdline
141
142#endif // WXM_COMMANDLINEOPTIONS_H
constexpr std::array< std::string_view, 10 > OpenableExtensions
The extensions (without the dot, lower case) of the files wxMaxima opens.
Definition: CommandLineOptions.h:137
constexpr std::array Options
Every option wxMaxima understands, in the order –help lists them.
Definition: CommandLineOptions.h:74
Kind
Whether an entry is a bare switch or takes a value.
Definition: CommandLineOptions.h:47
constexpr std::string_view ParamDescription
The description of the positional arguments (the files to open)
Definition: CommandLineOptions.h:128
Complete
What a shell should offer to complete the value of an option with.
Definition: CommandLineOptions.h:50
@ Openable
A file wxMaxima opens (see OpenableExtensions)
@ AnyFile
Any file (or program: a path, too)
@ Nothing
Free text: offer nothing.
One command-line option.
Definition: CommandLineOptions.h:57
std::string_view valueName
For an Option: what the value is called in the man page.
Definition: CommandLineOptions.h:66
std::string_view description
The text –help, the man page and the completions show (not translated)
Definition: CommandLineOptions.h:64
std::string_view longName
Long name, used without its leading "--".
Definition: CommandLineOptions.h:62
std::string_view shortName
One-letter name, or empty if there is none.
Definition: CommandLineOptions.h:60
bool isHelp
True for the entry wxCmdLineParser treats as "show the help".
Definition: CommandLineOptions.h:70
Complete complete
For an Option: what the shell completes its value with.
Definition: CommandLineOptions.h:68