Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
ccd96bb4
Commit
ccd96bb4
authored
Feb 15, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --export command line flag for using export templates, --export-image now export images
parent
57ea6d26
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
67 deletions
+112
-67
src/cli/cli_main.cpp
src/cli/cli_main.cpp
+2
-10
src/cli/cli_main.hpp
src/cli/cli_main.hpp
+0
-1
src/cli/text_io_handler.cpp
src/cli/text_io_handler.cpp
+20
-5
src/cli/text_io_handler.hpp
src/cli/text_io_handler.hpp
+1
-0
src/cli/win32_cli_wrapper.cpp
src/cli/win32_cli_wrapper.cpp
+20
-2
src/main.cpp
src/main.cpp
+69
-49
No files found.
src/cli/cli_main.cpp
View file @
ccd96bb4
...
...
@@ -34,7 +34,7 @@ CLISetInterface::CLISetInterface(const SetP& set, bool quiet)
setSet
(
set
);
// show welcome logo
if
(
!
quiet
)
showWelcome
();
print_pending_errors
();
cli
.
print_pending_errors
();
}
CLISetInterface
::~
CLISetInterface
()
{
...
...
@@ -90,7 +90,7 @@ void CLISetInterface::run_interactive() {
String
command
=
cli
.
getLine
();
if
(
command
.
empty
()
&&
!
cli
.
canGetLine
())
break
;
handleCommand
(
command
);
print_pending_errors
();
cli
.
print_pending_errors
();
cli
.
flush
();
cli
.
flushRaw
();
}
...
...
@@ -272,11 +272,3 @@ void CLISetInterface::handleCommand(const String& command) {
}
}
#endif
void
CLISetInterface
::
print_pending_errors
()
{
MessageType
type
;
String
msg
;
while
(
get_queued_message
(
type
,
msg
))
{
cli
.
show_message
(
type
,
msg
);
}
}
src/cli/cli_main.hpp
View file @
ccd96bb4
...
...
@@ -40,7 +40,6 @@ class CLISetInterface : public SetView {
#if USE_SCRIPT_PROFILING
void
showProfilingStats
(
const
FunctionProfile
&
parent
,
int
level
=
0
);
#endif
void
print_pending_errors
();
/// our own context, when no set is loaded
Context
&
getContext
();
...
...
src/cli/text_io_handler.cpp
View file @
ccd96bb4
...
...
@@ -55,7 +55,7 @@ void TextIOHandler::init() {
have_console
=
false
;
have_stderr
=
false
;
// Use console mode if one of the cli flags is passed
static
const
Char
*
redirect_flags
[]
=
{
_
(
"-?"
),
_
(
"--help"
),
_
(
"-v"
),
_
(
"--version"
),
_
(
"--cli"
),
_
(
"-c"
),
_
(
"--export"
),
_
(
"--create-installer"
)};
static
const
Char
*
redirect_flags
[]
=
{
_
(
"-?"
),
_
(
"--help"
),
_
(
"-v"
),
_
(
"--version"
),
_
(
"--cli"
),
_
(
"-c"
),
_
(
"--export"
),
_
(
"--
export-images"
),
_
(
"--
create-installer"
)};
for
(
int
i
=
1
;
i
<
wxTheApp
->
argc
;
++
i
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
redirect_flags
)
/
sizeof
(
redirect_flags
[
0
])
;
++
j
)
{
if
(
String
(
wxTheApp
->
argv
[
i
])
==
redirect_flags
[
j
])
{
...
...
@@ -152,12 +152,12 @@ void TextIOHandler::flushRaw() {
if
(
!
buffer
.
empty
())
{
#ifdef UNICODE
wxCharBuffer
buf
=
buffer
.
mb_str
(
wxConvUTF8
);
fputs
(
buf
,
st
dout
);
fputs
(
buf
,
st
ream
);
#else
fputs
(
buffer
.
c_str
(),
st
dout
);
fputs
(
buffer
.
c_str
(),
st
ream
);
#endif
}
fflush
(
st
dout
);
fflush
(
st
ream
);
// clear
buffer
.
clear
();
raw_mode_status
=
0
;
...
...
@@ -166,7 +166,8 @@ void TextIOHandler::flushRaw() {
// ----------------------------------------------------------------------------- : Errors
void
TextIOHandler
::
show_message
(
MessageType
type
,
String
const
&
message
)
{
stream
=
stdout
;
flush
();
stream
=
stderr
;
if
(
type
==
MESSAGE_WARNING
)
{
*
this
<<
YELLOW
<<
_
(
"WARNING: "
)
<<
NORMAL
<<
replace_all
(
message
,
_
(
"
\n
"
),
_
(
"
\n
"
))
<<
ENDL
;
}
else
{
...
...
@@ -176,3 +177,17 @@ void TextIOHandler::show_message(MessageType type, String const& message) {
stream
=
stdout
;
if
(
raw_mode
)
raw_mode_status
=
max
(
raw_mode_status
,
type
==
MESSAGE_WARNING
?
1
:
2
);
}
void
TextIOHandler
::
print_pending_errors
()
{
MessageType
type
;
String
msg
;
while
(
get_queued_message
(
type
,
msg
))
{
if
(
haveConsole
())
{
cli
.
show_message
(
type
,
msg
);
cli
.
flush
();
}
else
{
// no console, use a messagebox instead
wxMessageBox
(
msg
,
wxMessageBoxCaptionStr
,
type
==
MESSAGE_INFO
?
wxICON_INFORMATION
:
type
==
MESSAGE_WARNING
?
wxICON_WARNING
:
wxICON_ERROR
);
}
}
}
src/cli/text_io_handler.hpp
View file @
ccd96bb4
...
...
@@ -38,6 +38,7 @@ class TextIOHandler {
/// Show an error or warning message
void
show_message
(
MessageType
type
,
String
const
&
message
);
void
print_pending_errors
();
/// Enable raw mode
void
enableRaw
();
...
...
src/cli/win32_cli_wrapper.cpp
View file @
ccd96bb4
...
...
@@ -45,6 +45,7 @@ DWORD WINAPI TransferThread(Transfer*);
BOOL
WINAPI
HandleCtrlEvent
(
DWORD
type
);
void
CopyFileBuffer
(
HANDLE
output
,
char
*
buffer
,
DWORD
size
);
void
InitEscapeTranslation
(
HANDLE
console
);
void
FinishEscapeTranslation
(
HANDLE
console
);
void
PerformEscapeCode
(
HANDLE
console
,
char
command
,
int
argc
,
int
argv
[]);
/// The child process
...
...
@@ -54,14 +55,15 @@ PROCESS_INFORMATION child_process_info;
HANDLE
in_mine
,
in_theirs
,
in_real
;
HANDLE
out_mine
,
out_theirs
,
out_real
;
HANDLE
err_mine
,
err_theirs
,
err_real
;
bool
need_redirection
;
// ----------------------------------------------------------------------------- : Main function
const
char
*
redirect_flags
[]
=
{
"-?"
,
"
--help"
,
"-v"
,
"--version"
,
"--cli"
,
"-c"
,
"--export
"
,
"--create-installer"
};
const
char
*
redirect_flags
[]
=
{
"-?"
,
"
/?"
,
"--help"
,
"-v"
,
"--version"
,
"--cli"
,
"-c"
,
"--export"
,
"--export-images
"
,
"--create-installer"
};
int
main
(
int
argc
,
char
**
argv
)
{
// determine whether we need to wrap console i/o
bool
need_redirection
=
false
;
need_redirection
=
false
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
for
(
int
j
=
0
;
j
<
sizeof
(
redirect_flags
)
/
sizeof
(
redirect_flags
[
0
])
;
++
j
)
{
if
(
strcmp
(
argv
[
i
],
redirect_flags
[
j
])
==
0
)
{
...
...
@@ -115,6 +117,7 @@ int main(int argc, char** argv) {
out_real
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
err_real
=
GetStdHandle
(
STD_ERROR_HANDLE
);
InitEscapeTranslation
(
out_real
);
InitEscapeTranslation
(
err_real
);
// start threads
Transfer
tranfer_in
=
{
in_real
,
in_mine
,
false
};
...
...
@@ -134,6 +137,7 @@ int main(int argc, char** argv) {
// start the child program
if
(
!
CreateProcess
(
app_path
,
command_line
,
NULL
,
NULL
,
TRUE
,
0
,
NULL
,
NULL
,
&
child_startup_info
,
&
child_process_info
))
{
fprintf
(
stderr
,
"Unable to start child process.
\n
"
);
ExitProcess
(
1
);
}
...
...
@@ -146,6 +150,10 @@ int main(int argc, char** argv) {
}
// That's all folks!
if
(
need_redirection
)
{
FinishEscapeTranslation
(
out_real
);
FinishEscapeTranslation
(
err_real
);
}
return
exit_code
;
}
...
...
@@ -168,6 +176,10 @@ BOOL WINAPI HandleCtrlEvent(DWORD type) {
TerminateProcess
(
child_process_info
.
hProcess
,
1
);
}
// exit this process
if
(
need_redirection
)
{
FinishEscapeTranslation
(
out_real
);
FinishEscapeTranslation
(
err_real
);
}
ExitProcess
(
exit_code
);
return
TRUE
;
}
...
...
@@ -251,6 +263,12 @@ void InitEscapeTranslation(HANDLE console) {
original_attributes
=
screen_buffer
.
wAttributes
;
}
/// Cleanup for escape translation: put things back to normal
void
FinishEscapeTranslation
(
HANDLE
console
)
{
CONSOLE_SCREEN_BUFFER_INFO
screen_buffer
;
SetConsoleTextAttribute
(
console
,
original_attributes
);
}
/// Perform an escape code
void
PerformEscapeCode
(
HANDLE
console
,
char
command
,
int
argc
,
int
argv
[])
{
switch
(
command
)
{
...
...
src/main.cpp
View file @
ccd96bb4
...
...
@@ -28,6 +28,8 @@
#include <wx/txtstrm.h>
#include <wx/socket.h>
ScriptValueP
export_set
(
SetP
const
&
set
,
vector
<
CardP
>
const
&
cards
,
ExportTemplateP
const
&
exp
,
String
const
&
outname
);
DECLARE_TYPEOF_COLLECTION
(
String
);
// ----------------------------------------------------------------------------- : Main function/class
...
...
@@ -98,44 +100,47 @@ int MSE::OnRun() {
nag_about_ascii_version
();
// interpret command line
if
(
argc
>
1
)
{
try
{
String
arg
=
argv
[
1
];
{
vector
<
String
>
args
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
args
.
push_back
(
argv
[
i
]);
if
(
args
.
back
()
==
_
(
"--color"
))
args
.
pop_back
();
// ingnore the --color argument, it is handled by cli.init()
}
if
(
!
args
.
empty
())
{
// Find the extension
wxFileName
f
(
arg
.
Mid
(
0
,
arg
.
find_last_not_of
(
_
(
"
\\
/"
))
+
1
));
wxFileName
f
(
arg
s
[
0
].
Mid
(
0
,
args
[
0
]
.
find_last_not_of
(
_
(
"
\\
/"
))
+
1
));
if
(
f
.
GetExt
()
==
_
(
"mse-symbol"
))
{
// Show the symbol editor
Window
*
wnd
=
new
SymbolWindow
(
nullptr
,
arg
v
[
1
]);
Window
*
wnd
=
new
SymbolWindow
(
nullptr
,
arg
s
[
0
]);
wnd
->
Show
();
return
runGUI
();
}
else
if
(
f
.
GetExt
()
==
_
(
"mse-set"
)
||
f
.
GetExt
()
==
_
(
"mse"
)
||
f
.
GetExt
()
==
_
(
"set"
))
{
// Show the set window
Window
*
wnd
=
new
SetWindow
(
nullptr
,
import_set
(
arg
v
[
1
]));
Window
*
wnd
=
new
SetWindow
(
nullptr
,
import_set
(
arg
s
[
0
]));
wnd
->
Show
();
return
runGUI
();
}
else
if
(
f
.
GetExt
()
==
_
(
"mse-installer"
))
{
// Installer; install it
InstallType
type
=
settings
.
install_type
;
if
(
argc
>
2
)
{
String
arg
=
argv
[
2
];
if
(
starts_with
(
argv
[
2
],
_
(
"--"
))
&&
arg
!=
_
(
"--color"
))
{
parse_enum
(
String
(
argv
[
2
]).
substr
(
2
),
type
);
if
(
args
.
size
()
>=
2
)
{
if
(
starts_with
(
args
[
1
],
_
(
"--"
)))
{
parse_enum
(
String
(
args
[
1
]).
substr
(
2
),
type
);
}
}
InstallerP
installer
=
open_package
<
Installer
>
(
arg
v
[
1
]);
InstallerP
installer
=
open_package
<
Installer
>
(
arg
s
[
0
]);
PackagesWindow
wnd
(
nullptr
,
installer
);
wnd
.
ShowModal
();
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--symbol-editor"
))
{
}
else
if
(
arg
s
[
0
]
==
_
(
"--symbol-editor"
))
{
Window
*
wnd
=
new
SymbolWindow
(
nullptr
);
wnd
->
Show
();
return
runGUI
();
}
else
if
(
arg
==
_
(
"--create-installer"
))
{
}
else
if
(
arg
s
[
0
]
==
_
(
"--create-installer"
))
{
// create an installer
Installer
inst
;
for
(
int
i
=
2
;
i
<
argc
;
++
i
)
{
if
(
!
starts_with
(
arg
v
[
i
]
,
_
(
"--"
)))
{
inst
.
addPackage
(
arg
v
[
i
]
);
FOR_EACH
(
arg
,
args
)
{
if
(
!
starts_with
(
arg
,
_
(
"--"
)))
{
inst
.
addPackage
(
arg
);
}
}
if
(
inst
.
prefered_filename
.
empty
())
{
...
...
@@ -144,43 +149,46 @@ int MSE::OnRun() {
inst
.
saveAs
(
inst
.
prefered_filename
,
false
);
}
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--help"
)
||
arg
==
_
(
"-
?"
))
{
}
else
if
(
arg
s
[
0
]
==
_
(
"--help"
)
||
args
[
0
]
==
_
(
"-?"
)
||
args
[
0
]
==
_
(
"/
?"
))
{
// command line help
cli
<<
_
(
"Magic Set Editor
\n\n
"
);
cli
<<
_
(
"Usage: "
)
<<
BRIGHT
<<
argv
[
0
]
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"OPTIONS"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n\n
no options"
);
cli
<<
_
(
"
\n
\t
Start the MSE user interface showing the welcome window."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"-?"
)
<<
NORMAL
<<
_
(
", "
)
<<
BRIGHT
<<
_
(
"--help"
)
<<
NORMAL
;
<<
BRIGHT
<<
_
(
"--help"
)
<<
NORMAL
;
cli
<<
_
(
"
\n
\t
Shows this help screen."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"-v"
)
<<
NORMAL
<<
_
(
", "
)
<<
BRIGHT
<<
_
(
"--version"
)
<<
NORMAL
;
<<
BRIGHT
<<
_
(
"--version"
)
<<
NORMAL
;
cli
<<
_
(
"
\n
\t
Show version information."
);
cli
<<
_
(
"
\n\n
"
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".mse-set"
)
<<
NORMAL
<<
_
(
", "
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".set"
)
<<
NORMAL
<<
_
(
", "
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".mse"
)
<<
NORMAL
;
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".set"
)
<<
NORMAL
<<
_
(
", "
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".mse"
)
<<
NORMAL
;
cli
<<
_
(
"
\n
\t
Load the set file in the MSE user interface."
);
cli
<<
_
(
"
\n\n
"
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".mse-symbol"
)
<<
NORMAL
;
cli
<<
_
(
"
\n
\t
Load the symbol into the MSE symbol editor."
);
cli
<<
_
(
"
\n\n
"
)
<<
PARAM
<<
_
(
"FILE"
)
<<
FILE_EXT
<<
_
(
".mse-installer"
)
<<
NORMAL
<<
_
(
" ["
)
<<
BRIGHT
<<
_
(
"--local"
)
<<
NORMAL
<<
_
(
"]"
);
<<
NORMAL
<<
_
(
" ["
)
<<
BRIGHT
<<
_
(
"--local"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n
\t
Install the packages from the installer."
);
cli
<<
_
(
"
\n
\t
If the "
)
<<
BRIGHT
<<
_
(
"--local"
)
<<
NORMAL
<<
_
(
" flag is passed, install packages for this user only."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--symbol-editor"
)
<<
NORMAL
;
cli
<<
_
(
"
\n
\t
Show the symbol editor instead of the welcome window."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--create-installer"
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"OUTFILE"
)
<<
FILE_EXT
<<
_
(
".mse-installer"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
PARAM
<<
_
(
"PACKAGE"
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"PACKAGE"
)
<<
NORMAL
<<
_
(
" ...]]"
);
<<
PARAM
<<
_
(
"OUTFILE"
)
<<
FILE_EXT
<<
_
(
".mse-installer"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
PARAM
<<
_
(
"PACKAGE"
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"PACKAGE"
)
<<
NORMAL
<<
_
(
" ...]]"
);
cli
<<
_
(
"
\n
\t
Create an instaler, containing the listed packages."
);
cli
<<
_
(
"
\n
\t
If no output filename is specified, the name of the first package is used."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--export"
)
<<
NORMAL
<<
PARAM
<<
_
(
" FILE"
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"IMAGE"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--export"
)
<<
NORMAL
<<
PARAM
<<
_
(
" TEMPLATE SETFILE "
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"OUTFILE"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n
\t
Export a set using an export template."
);
cli
<<
_
(
"
\n
\t
If no output filename is specified, the result is written to stdout."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--export-images"
)
<<
NORMAL
<<
PARAM
<<
_
(
" SETFILE"
)
<<
NORMAL
<<
_
(
" ["
)
<<
PARAM
<<
_
(
"IMAGE"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n
\t
Export the cards in a set to image files,"
);
cli
<<
_
(
"
\n
\t
IMAGE is the same format as for 'export all card images'."
);
cli
<<
_
(
"
\n\n
"
)
<<
BRIGHT
<<
_
(
"--cli"
)
<<
NORMAL
<<
_
(
" ["
)
<<
BRIGHT
<<
_
(
"--quiet"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
BRIGHT
<<
_
(
"--raw"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
BRIGHT
<<
_
(
"--script "
)
<<
NORMAL
<<
PARAM
<<
_
(
"FILE"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
PARAM
<<
_
(
"SETFILE"
)
<<
NORMAL
<<
_
(
"]"
);
<<
BRIGHT
<<
_
(
"--quiet"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
BRIGHT
<<
_
(
"--raw"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
BRIGHT
<<
_
(
"--script "
)
<<
NORMAL
<<
PARAM
<<
_
(
"FILE"
)
<<
NORMAL
<<
_
(
"] ["
)
<<
PARAM
<<
_
(
"SETFILE"
)
<<
NORMAL
<<
_
(
"]"
);
cli
<<
_
(
"
\n
\t
Start the command line interface for performing commands on the set file."
);
cli
<<
_
(
"
\n
\t
Use "
)
<<
BRIGHT
<<
_
(
"-q"
)
<<
NORMAL
<<
_
(
" or "
)
<<
BRIGHT
<<
_
(
"--quiet"
)
<<
NORMAL
<<
_
(
" to supress the startup banner and prompts."
);
cli
<<
_
(
"
\n
\t
Use "
)
<<
BRIGHT
<<
_
(
"--raw"
)
<<
NORMAL
<<
_
(
" for raw output mode."
);
...
...
@@ -195,20 +203,20 @@ int MSE::OnRun() {
cli
<<
ENDL
;
cli
.
flush
();
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--version"
)
||
arg
==
_
(
"-v
"
))
{
}
else
if
(
arg
s
[
0
]
==
_
(
"--version"
)
||
args
[
0
]
==
_
(
"-v"
)
||
args
[
0
]
==
_
(
"-V
"
))
{
// dump version
cli
<<
_
(
"Magic Set Editor
\n
"
);
cli
<<
_
(
"Version "
)
<<
app_version
.
toString
()
<<
version_suffix
<<
ENDL
;
cli
.
flush
();
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--cli"
))
{
}
else
if
(
arg
s
[
0
]
==
_
(
"--cli"
))
{
// command line interface
SetP
set
;
vector
<
String
>
scripts
;
bool
quiet
=
false
;
for
(
int
i
=
2
;
i
<
argc
;
++
i
)
{
String
arg
=
argv
[
i
];
wxFileName
f
(
arg
v
[
i
]
);
for
(
size_t
i
=
1
;
i
<
args
.
size
()
;
++
i
)
{
String
const
&
arg
=
args
[
i
];
wxFileName
f
(
arg
);
if
(
f
.
GetExt
()
==
_
(
"mse-set"
)
||
f
.
GetExt
()
==
_
(
"mse"
)
||
f
.
GetExt
()
==
_
(
"set"
))
{
set
=
import_set
(
arg
);
}
else
if
(
arg
==
_
(
"-q"
)
||
arg
==
_
(
"--quiet"
)
||
arg
==
_
(
"--silent"
))
{
...
...
@@ -216,13 +224,13 @@ int MSE::OnRun() {
}
else
if
(
arg
==
_
(
"-r"
)
||
arg
==
_
(
"--raw"
))
{
quiet
=
true
;
cli
.
enableRaw
();
}
else
if
((
arg
==
_
(
"-s"
)
||
arg
==
_
(
"--script"
))
&&
i
+
1
<
arg
c
)
{
scripts
.
push_back
(
arg
v
[
i
+
1
]);
}
else
if
((
arg
==
_
(
"-s"
)
||
arg
==
_
(
"--script"
))
&&
i
+
1
<
arg
s
.
size
()
)
{
scripts
.
push_back
(
arg
s
[
i
+
1
]);
++
i
;
}
else
if
(
arg
==
_
(
"--color"
))
{
// ignore
}
else
{
handle_error
(
_
(
"Invalid command line argument: "
)
+
String
(
argv
[
i
])
);
throw
Error
(
_
(
"Invalid command line argument: "
)
+
arg
);
}
}
CLISetInterface
cli_interface
(
set
,
quiet
);
...
...
@@ -234,16 +242,15 @@ int MSE::OnRun() {
}
}
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--export"
))
{
if
(
argc
<=
2
||
(
argc
<=
3
&&
starts_with
(
argv
[
2
],
_
(
"--"
))))
{
handle_error
(
Error
(
_
(
"No input file specified for --export"
)));
return
EXIT_FAILURE
;
}
else
if
(
args
[
0
]
==
_
(
"--export-images"
))
{
if
(
args
.
size
()
<
2
)
{
throw
Error
(
_
(
"No input file specified for --export-images"
));
}
SetP
set
=
import_set
(
arg
v
[
2
]);
SetP
set
=
import_set
(
arg
s
[
1
]);
// path
String
out
=
arg
c
>=
3
&&
!
starts_with
(
argv
[
3
],
_
(
"--"
))
?
argv
[
3
]
:
settings
.
gameSettingsFor
(
*
set
->
game
).
images_export_filename
;
String
out
=
arg
s
.
size
()
>=
3
?
args
[
2
]
:
settings
.
gameSettingsFor
(
*
set
->
game
).
images_export_filename
;
String
path
=
_
(
"."
);
size_t
pos
=
out
.
find_last_of
(
_
(
"/
\\
"
));
if
(
pos
!=
String
::
npos
)
{
...
...
@@ -255,12 +262,24 @@ int MSE::OnRun() {
// export
export_images
(
set
,
set
->
cards
,
path
,
out
,
CONFLICT_NUMBER_OVERWRITE
);
return
EXIT_SUCCESS
;
}
else
if
(
args
[
0
]
==
_
(
"--export"
))
{
if
(
args
.
size
()
<
2
)
{
throw
Error
(
_
(
"No export template specified for --export"
));
}
else
if
(
args
.
size
()
<
3
)
{
throw
Error
(
_
(
"No input set file specified for --export"
));
}
String
export_template
=
args
[
1
];
ExportTemplateP
exp
=
package_manager
.
open
<
ExportTemplate
>
(
export_template
);
SetP
set
=
import_set
(
args
[
2
]);
String
out
=
args
.
size
()
>=
4
?
args
[
3
]
:
wxEmptyString
;
ScriptValueP
result
=
export_set
(
set
,
set
->
cards
,
exp
,
out
);
if
(
out
.
empty
())
{
cli
<<
result
->
toString
();
}
return
EXIT_SUCCESS
;
}
else
{
handle_error
(
_
(
"Invalid command line argument: "
)
+
String
(
argv
[
1
])
);
throw
Error
(
_
(
"Invalid command line argument: "
)
+
args
[
0
]
);
}
}
catch
(
const
Error
&
e
)
{
handle_error
(
e
);
return
EXIT_FAILURE
;
}
}
...
...
@@ -269,6 +288,7 @@ int MSE::OnRun() {
return
runGUI
();
}
CATCH_ALL_ERRORS
(
true
);
cli
.
print_pending_errors
();
return
EXIT_FAILURE
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment