| 1 | // Aseprite | 
|---|
| 2 | // Copyright (C) 2020  Igara Studio S.A. | 
|---|
| 3 | // Copyright (C) 2001-2016  David Capello | 
|---|
| 4 | // | 
|---|
| 5 | // This program is distributed under the terms of | 
|---|
| 6 | // the End-User License Agreement for Aseprite. | 
|---|
| 7 |  | 
|---|
| 8 | #ifdef HAVE_CONFIG_H | 
|---|
| 9 | #include "config.h" | 
|---|
| 10 | #endif | 
|---|
| 11 |  | 
|---|
| 12 | #ifndef ENABLE_SCRIPTING | 
|---|
| 13 | #error ENABLE_SCRIPTING must be defined | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include "app/shell.h" | 
|---|
| 17 |  | 
|---|
| 18 | #include "fmt/format.h" | 
|---|
| 19 | #include "script/engine.h" | 
|---|
| 20 | #include "ver/info.h" | 
|---|
| 21 |  | 
|---|
| 22 | #include <iostream> | 
|---|
| 23 | #include <string> | 
|---|
| 24 |  | 
|---|
| 25 | namespace app { | 
|---|
| 26 |  | 
|---|
| 27 | Shell::Shell() | 
|---|
| 28 | { | 
|---|
| 29 | } | 
|---|
| 30 |  | 
|---|
| 31 | Shell::~Shell() | 
|---|
| 32 | { | 
|---|
| 33 | } | 
|---|
| 34 |  | 
|---|
| 35 | void Shell::run(script::Engine& engine) | 
|---|
| 36 | { | 
|---|
| 37 | std::cout << fmt::format( "Welcome to {} v{} Interactive Console", | 
|---|
| 38 | get_app_name(), get_app_version()) << std::endl; | 
|---|
| 39 | std::string line; | 
|---|
| 40 | while (std::getline(std::cin, line)) { | 
|---|
| 41 | engine.evalCode(line); | 
|---|
| 42 | } | 
|---|
| 43 | std::cout << "Done\n"; | 
|---|
| 44 | } | 
|---|
| 45 |  | 
|---|
| 46 | } // namespace app | 
|---|
| 47 |  | 
|---|