diff options
| author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2012-02-23 19:05:12 +0100 | 
|---|---|---|
| committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2012-02-23 19:05:12 +0100 | 
| commit | 93e1c741d591be11d4782ec359d33a3f1b54bf8c (patch) | |
| tree | cfb0cf2bf706e6a6613e5a305fa8b5881b652282 /scripts/context | |
| parent | b17163c6ef0c5d84456874f67d198e844e4d774f (diff) | |
| download | enigma-93e1c741d591be11d4782ec359d33a3f1b54bf8c.tar.gz | |
mtx-script
Diffstat (limited to 'scripts/context')
| -rw-r--r-- | scripts/context/lua/third/enigma/mtx-t-enigma.lua | 62 | 
1 files changed, 62 insertions, 0 deletions
| diff --git a/scripts/context/lua/third/enigma/mtx-t-enigma.lua b/scripts/context/lua/third/enigma/mtx-t-enigma.lua new file mode 100644 index 0000000..8c84385 --- /dev/null +++ b/scripts/context/lua/third/enigma/mtx-t-enigma.lua @@ -0,0 +1,62 @@ +-- +-------------------------------------------------------------------------------- +--         FILE:  mtx-transliterate.lua +--        USAGE:  mtxrun --script transliterate [--mode=mode] --s="string" +--  DESCRIPTION:  context script interface for the Transliterator module +-- REQUIREMENTS:  latest ConTeXt MkIV +--       AUTHOR:  Philipp Gesang (Phg), <gesang@stud.uni-heidelberg.de> +--      CREATED:  2011-06-11T16:14:16+0200 +-------------------------------------------------------------------------------- +-- + +environment.loadluafile("enigma") + +local helpinfo = [[ +=============================================================== +    The Enigma module, command line interface. +    © 2012 Philipp Gesang. License: 2-clause BSD. +    Home: <https://bitbucket.org/phg/enigma/> +=============================================================== + +USAGE: + +    mtxrun --script enigma --setup="settings" --text="text" +           --verbose=int + +    where the settings are to be specified as a comma-delimited +    conjunction of “key=value” statements, and “text” refers to +    the text to be encoded. Note that due to the involutory +    design of the enigma cipher, the text can be both plaintext +    and ciphertext. + +=============================================================== +]] + +local application = logs.application { +    name     = "mtx-t-enigma", +    banner   = "The Enigma for ConTeXt, hg-rev 9+", +    helpinfo = helpinfo, +} + +local ea = environment.argument + +local setup, text = ea"setup" or ea"s",  ea"text" or ea"t" +local verbose     = ea"verbose" or ea"v" + +local out = function (str) +  io.write(str) +end + +if setup and text then +  local machine = enigma.new_machine(enigma.parse_args(setup)) +  machine.name  = "external" +  local result  = machine:encode_string(text) +  if result then +    out(result) +  else +    application.help() +  end +else +    application.help() +end + | 
