1// Aseprite
2// Copyright (C) 2018-2022 Igara Studio S.A.
3// Copyright (C) 2001-2017 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef APP_CLI_APP_OPTIONS_H_INCLUDED
9#define APP_CLI_APP_OPTIONS_H_INCLUDED
10#pragma once
11
12#include <stdexcept>
13#include <string>
14#include <vector>
15
16#include "base/program_options.h"
17
18namespace app {
19
20class AppOptions {
21public:
22 enum VerboseLevel {
23 kNoVerbose,
24 kVerbose,
25 kHighlyVerbose,
26 };
27
28 typedef base::ProgramOptions PO;
29 typedef PO::Option Option;
30 typedef PO::ValueList ValueList;
31
32 AppOptions(int argc, const char* argv[]);
33
34 const std::string& exeName() const { return m_exeName; }
35 const base::ProgramOptions& programOptions() const { return m_po; }
36
37 bool startUI() const { return m_startUI; }
38 bool startShell() const { return m_startShell; }
39 bool previewCLI() const { return m_previewCLI; }
40 bool showHelp() const { return m_showHelp; }
41 bool showVersion() const { return m_showVersion; }
42 VerboseLevel verboseLevel() const { return m_verboseLevel; }
43
44 const ValueList& values() const {
45 return m_po.values();
46 }
47
48 // Export options
49 const Option& saveAs() const { return m_saveAs; }
50 const Option& palette() const { return m_palette; }
51 const Option& scale() const { return m_scale; }
52 const Option& ditheringAlgorithm() const { return m_ditheringAlgorithm; }
53 const Option& ditheringMatrix() const { return m_ditheringMatrix; }
54 const Option& colorMode() const { return m_colorMode; }
55 const Option& shrinkTo() const { return m_shrinkTo; }
56 const Option& data() const { return m_data; }
57 const Option& format() const { return m_format; }
58 const Option& sheet() const { return m_sheet; }
59 const Option& sheetType() const { return m_sheetType; }
60 const Option& sheetPack() const { return m_sheetPack; }
61 const Option& sheetWidth() const { return m_sheetWidth; }
62 const Option& sheetHeight() const { return m_sheetHeight; }
63 const Option& sheetColumns() const { return m_sheetColumns; }
64 const Option& sheetRows() const { return m_sheetRows; }
65 const Option& splitLayers() const { return m_splitLayers; }
66 const Option& splitTags() const { return m_splitTags; }
67 const Option& splitSlices() const { return m_splitSlices; }
68 const Option& splitGrid() const { return m_splitGrid; }
69 const Option& layer() const { return m_layer; }
70 const Option& allLayers() const { return m_allLayers; }
71 const Option& ignoreLayer() const { return m_ignoreLayer; }
72 const Option& tag() const { return m_tag; }
73 const Option& frameRange() const { return m_frameRange; }
74 const Option& ignoreEmpty() const { return m_ignoreEmpty; }
75 const Option& mergeDuplicates() const { return m_mergeDuplicates; }
76 const Option& borderPadding() const { return m_borderPadding; }
77 const Option& shapePadding() const { return m_shapePadding; }
78 const Option& innerPadding() const { return m_innerPadding; }
79 const Option& trim() const { return m_trim; }
80 const Option& trimSprite() const { return m_trimSprite; }
81 const Option& trimByGrid() const { return m_trimByGrid; }
82 const Option& extrude() const { return m_extrude; }
83 const Option& crop() const { return m_crop; }
84 const Option& slice() const { return m_slice; }
85 const Option& filenameFormat() const { return m_filenameFormat; }
86#ifdef ENABLE_SCRIPTING
87 const Option& script() const { return m_script; }
88 const Option& scriptParam() const { return m_scriptParam; }
89#endif
90 const Option& listLayers() const { return m_listLayers; }
91 const Option& listTags() const { return m_listTags; }
92 const Option& listSlices() const { return m_listSlices; }
93 const Option& oneFrame() const { return m_oneFrame; }
94 const Option& exportTileset() const { return m_exportTileset; }
95
96 bool hasExporterParams() const;
97#ifdef _WIN32
98 bool disableWintab() const;
99#endif
100
101private:
102 AppOptions(const AppOptions& that);
103
104 std::string m_exeName;
105 base::ProgramOptions m_po;
106 bool m_startUI;
107 bool m_startShell;
108 bool m_previewCLI;
109 bool m_showHelp;
110 bool m_showVersion;
111 VerboseLevel m_verboseLevel;
112
113#ifdef ENABLE_SCRIPTING
114 Option& m_shell;
115#endif
116 Option& m_batch;
117 Option& m_preview;
118 Option& m_saveAs;
119 Option& m_palette;
120 Option& m_scale;
121 Option& m_ditheringAlgorithm;
122 Option& m_ditheringMatrix;
123 Option& m_colorMode;
124 Option& m_shrinkTo;
125 Option& m_data;
126 Option& m_format;
127 Option& m_sheet;
128 Option& m_sheetType;
129 Option& m_sheetPack;
130 Option& m_sheetWidth;
131 Option& m_sheetHeight;
132 Option& m_sheetColumns;
133 Option& m_sheetRows;
134 Option& m_splitLayers;
135 Option& m_splitTags;
136 Option& m_splitSlices;
137 Option& m_splitGrid;
138 Option& m_layer;
139 Option& m_allLayers;
140 Option& m_ignoreLayer;
141 Option& m_tag;
142 Option& m_frameRange;
143 Option& m_ignoreEmpty;
144 Option& m_mergeDuplicates;
145 Option& m_borderPadding;
146 Option& m_shapePadding;
147 Option& m_innerPadding;
148 Option& m_trim;
149 Option& m_trimSprite;
150 Option& m_trimByGrid;
151 Option& m_extrude;
152 Option& m_crop;
153 Option& m_slice;
154 Option& m_filenameFormat;
155#ifdef ENABLE_SCRIPTING
156 Option& m_script;
157 Option& m_scriptParam;
158#endif
159 Option& m_listLayers;
160 Option& m_listTags;
161 Option& m_listSlices;
162 Option& m_oneFrame;
163 Option& m_exportTileset;
164
165 Option& m_verbose;
166 Option& m_debug;
167#ifdef _WIN32
168 Option& m_disableWintab;
169#endif
170 Option& m_help;
171 Option& m_version;
172
173};
174
175} // namespace app
176
177#endif
178