LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
commandlineinterface.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_CLI_COMMANDLINEINTERFACE_H
21 #define LIBREPCB_CLI_COMMANDLINEINTERFACE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <QtCore>
27 
28 /*******************************************************************************
29  * Namespace / Forward Declarations
30  ******************************************************************************/
31 namespace librepcb {
32 
33 class Application;
34 class FilePath;
35 class TransactionalFileSystem;
36 
37 namespace library {
38 class LibraryBaseElement;
39 }
40 
41 namespace cli {
42 
43 /*******************************************************************************
44  * Class CommandLineInterface
45  ******************************************************************************/
46 
50 class CommandLineInterface final {
52 
53 public:
54  // Constructors / Destructor
55  CommandLineInterface() = delete;
56  explicit CommandLineInterface(const Application& app) noexcept;
57  ~CommandLineInterface() noexcept = default;
58 
59  // General Methods
60  int execute() noexcept;
61 
62 private: // Methods
63  bool openProject(const QString& projectFile, bool runErc,
64  const QStringList& exportSchematicsFiles,
65  const QStringList& exportBomFiles,
66  const QStringList& exportBoardBomFiles,
67  const QString& bomAttributes, bool exportPcbFabricationData,
68  const QString& pcbFabricationSettingsPath,
69  const QStringList& boards, bool save, bool strict) const
70  noexcept;
71  bool openLibrary(const QString& libDir, bool all, bool save,
72  bool strict) const noexcept;
73  void processLibraryElement(const QString& libDir, TransactionalFileSystem& fs,
74  library::LibraryBaseElement& element, bool save,
75  bool strict, bool& success) const;
76  static QString prettyPath(const FilePath& path,
77  const QString& style) noexcept;
78  static void print(const QString& str, int newlines = 1) noexcept;
79  static void printErr(const QString& str, int newlines = 1) noexcept;
80 
81 private: // Data
82  const Application& mApp;
83 };
84 
85 /*******************************************************************************
86  * End of File
87  ******************************************************************************/
88 
89 } // namespace cli
90 } // namespace librepcb
91 
92 #endif // LIBREPCB_CLI_COMMANDLINEINTERFACE_H
Special FileSystem implementation for libraries and projects.
Definition: transactionalfilesystem.h:63
static void printErr(const QString &str, int newlines=1) noexcept
Definition: commandlineinterface.cpp:718
bool openLibrary(const QString &libDir, bool all, bool save, bool strict) const noexcept
Definition: commandlineinterface.cpp:539
static QString prettyPath(const FilePath &path, const QString &style) noexcept
Definition: commandlineinterface.cpp:699
const Application & mApp
Definition: commandlineinterface.h:82
The LibraryBaseElement class.
Definition: librarybaseelement.h:52
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
~CommandLineInterface() noexcept=default
Q_DECLARE_TR_FUNCTIONS(CommandLineInterface)
bool openProject(const QString &projectFile, bool runErc, const QStringList &exportSchematicsFiles, const QStringList &exportBomFiles, const QStringList &exportBoardBomFiles, const QString &bomAttributes, bool exportPcbFabricationData, const QString &pcbFabricationSettingsPath, const QStringList &boards, bool save, bool strict) const noexcept
Definition: commandlineinterface.cpp:276
int execute() noexcept
Definition: commandlineinterface.cpp:66
static void print(const QString &str, int newlines=1) noexcept
Definition: commandlineinterface.cpp:710
void processLibraryElement(const QString &libDir, TransactionalFileSystem &fs, library::LibraryBaseElement &element, bool save, bool strict, bool &success) const
Definition: commandlineinterface.cpp:660
The Application class extends the QApplication with the exception-safe method notify() ...
Definition: application.h:57
The CommandLineInterface class.
Definition: commandlineinterface.h:50