From b1114caf4f8314205966a0e34b3302f0f1a3b1f4 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 29 Jun 2015 22:39:50 +0700 Subject: [PATCH] [console] Allow showing properties from command line. * sources/environment/commands/properties.dylan (parse-next-argument on ): New method for parsing an argument and converting it to a . * sources/environment/console/command-line.dylan (class ): Add slot for %show. (do-execute-command): Handle -show being passed by invoking the show property command. * sources/environment/console/compiler-command-line.dylan (command-line main): Add new show keyword parameter. * sources/environment/console/environment-command-line.dylan (command-line main): Add new show keyword parameter. --- sources/environment/commands/properties.dylan | 13 +++++++++++++ sources/environment/console/command-line.dylan | 4 ++++ .../environment/console/compiler-command-line.dylan | 2 ++ .../console/environment-command-line.dylan | 2 ++ 4 files changed, 21 insertions(+) diff --git a/sources/environment/commands/properties.dylan b/sources/environment/commands/properties.dylan index c9f77b1c4d..fd426145ac 100644 --- a/sources/environment/commands/properties.dylan +++ b/sources/environment/commands/properties.dylan @@ -20,6 +20,19 @@ define method parameter-type-name "property" end method parameter-type-name; +define method parse-next-argument + (context :: , type == , text :: , + #key start :: = 0, end: stop = #f) + => (value :: , next-index :: ) + let (name, next-index) + = parse-next-word(text, start: start, end: stop); + if (name) + values(find-named-property(context, as(, name)), next-index) + else + parse-error("Missing keyword argument") + end +end method parse-next-argument; + define open generic ensure-property-available (context :: , property :: ) => (); diff --git a/sources/environment/console/command-line.dylan b/sources/environment/console/command-line.dylan index 88f347b97c..98cdaf86d5 100644 --- a/sources/environment/console/command-line.dylan +++ b/sources/environment/console/command-line.dylan @@ -19,6 +19,8 @@ define abstract class () init-keyword: internal-debug:; constant slot %project :: false-or() = #f, init-keyword: project:; + constant slot %show :: false-or() = #f, + init-keyword: show:; constant slot %help? :: = #f, init-keyword: help?:; constant slot %logo? :: = #f, @@ -169,6 +171,8 @@ define method do-execute-command run() elseif (command.%shortversion?) run(, short: "short") + elseif (command.%show) + run(, property: command.%show); else command.%logo? & message(context, dylan-banner()); let personal-root = command.%personal-root; diff --git a/sources/environment/console/compiler-command-line.dylan b/sources/environment/console/compiler-command-line.dylan index ec8e57d90b..bbeb5ce753 100644 --- a/sources/environment/console/compiler-command-line.dylan +++ b/sources/environment/console/compiler-command-line.dylan @@ -28,6 +28,8 @@ define command-line main => flag echo-input = "echoes all input to the console"; flag verbose = "show verbose output"; + keyword show :: = "show a compiler setting"; + flag import = "import the project"; flag build = "build the project"; flag compile = "compile the project"; diff --git a/sources/environment/console/environment-command-line.dylan b/sources/environment/console/environment-command-line.dylan index c3c9419c50..9aa06f20f1 100644 --- a/sources/environment/console/environment-command-line.dylan +++ b/sources/environment/console/environment-command-line.dylan @@ -104,6 +104,8 @@ define command-line main => flag echo-input = "echoes all input to the console"; flag verbose = "show verbose output"; + keyword show :: = "show a compiler setting"; + flag import = "import the project"; flag build = "build the project"; flag compile = "compile the project";