LibrePCB Developers Documentation
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 {
51  Q_DECLARE_TR_FUNCTIONS(CommandLineInterface);
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 bool failIfFileFormatUnstable() noexcept;
79  static void print(const QString& str, int newlines = 1) noexcept;
80  static void printErr(const QString& str, int newlines = 1) noexcept;
81 
82 private: // Data
83  const Application& mApp;
84 };
85 
86 /*******************************************************************************
87  * End of File
88  ******************************************************************************/
89 
90 } // namespace cli
91 } // namespace librepcb
92 
93 #endif // LIBREPCB_CLI_COMMANDLINEINTERFACE_H
Transactional librepcb::FileSystem implementation.
Definition: transactionalfilesystem.h:63
Definition: alignment.cpp:30
const Application & mApp
Definition: commandlineinterface.h:83
The LibraryBaseElement class.
Definition: librarybaseelement.h:52
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
The Application class extends the QApplication with the exception-safe method notify() ...
Definition: application.h:59
The CommandLineInterface class.
Definition: commandlineinterface.h:50