remove unnesesary commandline params; :ports command
This commit is contained in:
parent
8fbeaea80d
commit
88f8fa7d75
@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Printing version number on non-quiet launch, or when provided `--version` or `:version`
|
||||
- Builtin function documentation generation from C++ Musique implementation source code
|
||||
- New builtins: digits
|
||||
- Connection with MIDI ports via parameters dropped in favour of function using context system: `port`
|
||||
- Listing ports via REPL command: `:ports` instead of commandline parameter
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -68,11 +68,6 @@ static T pop(std::span<char const*> &span)
|
||||
"usage: musique <options> [filename]\n"
|
||||
" where filename is path to file with Musique code that will be executed\n"
|
||||
" where options are:\n"
|
||||
" -o,--output PORT\n"
|
||||
" provides output port, a place where Musique produces MIDI messages\n"
|
||||
" -l,--list\n"
|
||||
" lists all available MIDI ports and quit\n"
|
||||
"\n"
|
||||
" -c,--run CODE\n"
|
||||
" executes given code\n"
|
||||
" -I,--interactive,--repl\n"
|
||||
@ -101,6 +96,7 @@ void print_repl_help()
|
||||
":!<command> - allows for execution of any shell command\n"
|
||||
":clear - clears screen\n"
|
||||
":load <file> - loads file into Musique session\n"
|
||||
":ports - print list available ports"
|
||||
;
|
||||
}
|
||||
|
||||
@ -163,13 +159,13 @@ struct Runner
|
||||
Interpreter interpreter;
|
||||
|
||||
/// Setup interpreter and midi connection with given port
|
||||
explicit Runner(std::optional<unsigned> output_port)
|
||||
explicit Runner()
|
||||
: interpreter{}
|
||||
{
|
||||
ensure(the == nullptr, "Only one instance of runner is supported");
|
||||
the = this;
|
||||
|
||||
interpreter.current_context->connect(output_port);
|
||||
interpreter.current_context->connect(std::nullopt);
|
||||
|
||||
Env::global->force_define("say", +[](Interpreter &interpreter, std::vector<Value> args) -> Result<Value> {
|
||||
for (auto it = args.begin(); it != args.end(); ++it) {
|
||||
@ -313,6 +309,14 @@ static Result<bool> handle_repl_session_commands(std::string_view input, Runner
|
||||
return std::nullopt;
|
||||
}
|
||||
},
|
||||
|
||||
Command {
|
||||
"ports",
|
||||
+[](Runner&, std::optional<std::string_view>) -> std::optional<Error> {
|
||||
midi::Rt_Midi{}.list_ports(std::cout);
|
||||
return {};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (input.starts_with('!')) {
|
||||
@ -357,9 +361,6 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
std::string_view argument;
|
||||
};
|
||||
|
||||
// Arbitraly chosen for conviniance of the author
|
||||
std::optional<unsigned> output_port{};
|
||||
|
||||
std::vector<Run> runnables;
|
||||
|
||||
while (not args.empty()) {
|
||||
@ -370,11 +371,6 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "-l" || arg == "--list") {
|
||||
midi::Rt_Midi{}.list_ports(std::cout);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (arg == "-c" || arg == "--run") {
|
||||
if (args.empty()) {
|
||||
std::cerr << "musique: error: option " << arg << " requires an argument" << std::endl;
|
||||
@ -407,15 +403,6 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "-o" || arg == "--output") {
|
||||
if (args.empty()) {
|
||||
std::cerr << "musique: error: option " << arg << " requires an argument" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
output_port = pop<unsigned>(args);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (arg == "-h" || arg == "--help") {
|
||||
usage();
|
||||
}
|
||||
@ -424,7 +411,7 @@ static std::optional<Error> Main(std::span<char const*> args)
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
Runner runner{output_port};
|
||||
Runner runner;
|
||||
|
||||
for (auto const& [type, argument] : runnables) {
|
||||
if (type == Run::Argument) {
|
||||
|
Loading…
Reference in New Issue
Block a user