From d860a921e061ca21e7af8c1c42f5bbca4bd5c988 Mon Sep 17 00:00:00 2001 From: hallgren Date: Wed, 12 Aug 2015 15:00:03 +0000 Subject: GF Shell: turn set_encoding into a common command Implemented in GF.Command.CommonCommands instead of GF.Interactive & GF.Interactive2. --- src/compiler/GF/Command/CommonCommands.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/compiler/GF/Command') diff --git a/src/compiler/GF/Command/CommonCommands.hs b/src/compiler/GF/Command/CommonCommands.hs index 4099d042f..e835d78d7 100644 --- a/src/compiler/GF/Command/CommonCommands.hs +++ b/src/compiler/GF/Command/CommonCommands.hs @@ -7,6 +7,8 @@ import GF.Command.CommandInfo import qualified Data.Map as Map import GF.Infra.SIO import GF.Infra.UseIO(writeUTF8File) +import GF.Infra.Option(renameEncoding) +import GF.System.Console(changeConsoleEncoding) import GF.System.Process import GF.Command.Abstract --(isOpt,valStrOpts,prOpt) import GF.Text.Pretty @@ -135,7 +137,14 @@ commonCommands = Map.fromList [ examples = [ mkEx "se cp1251 -- set encoding to cp1521", mkEx "se utf8 -- set encoding to utf8 (default)" - ] + ], + needsTypeCheck = False, + exec = \ _ opts ts -> + case words (toString ts) of + [c] -> do let cod = renameEncoding c + restricted $ changeConsoleEncoding cod + return void + _ -> return (pipeMessage "se command not parsed") }), ("sp", emptyCommandInfo { longname = "system_pipe", -- cgit v1.2.3