aboutsummaryrefslogtreecommitdiffstats
path: root/common/command.cc
diff options
context:
space:
mode:
Diffstat (limited to 'common/command.cc')
-rw-r--r--common/command.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/common/command.cc b/common/command.cc
index 7b0b2caa..1a8f810e 100644
--- a/common/command.cc
+++ b/common/command.cc
@@ -245,7 +245,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
#ifndef NO_GUI
if (vm.count("gui")) {
Application a(argc, argv, (vm.count("gui-no-aa") > 0));
- MainWindow w(std::move(ctx), chipArgs);
+ MainWindow w(std::move(ctx), this);
try {
if (vm.count("json")) {
std::string filename = vm["json"].as<std::string>();
@@ -378,6 +378,28 @@ int CommandHandler::exec()
}
}
+std::unique_ptr<Context> CommandHandler::load_json(std::string filename)
+{
+ vm.clear();
+ std::unordered_map<std::string,Property> values;
+ {
+ std::ifstream f(filename);
+ if (!load_json_settings(f, filename, values))
+ log_error("Loading design failed.\n");
+ }
+ std::unique_ptr<Context> ctx = createContext(values);
+ settings = std::unique_ptr<Settings>(new Settings(ctx.get()));
+ setupContext(ctx.get());
+ setupArchContext(ctx.get());
+ {
+ std::ifstream f(filename);
+ if (!parse_json_file(f, filename, ctx.get()))
+ log_error("Loading design failed.\n");
+ }
+ customAfterLoad(ctx.get());
+ return ctx;
+}
+
void CommandHandler::run_script_hook(const std::string &name)
{
#ifndef NO_PYTHON