Create CLI Framework/Libraries

Bug #844607 reported by Andrew Nicols
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Wishlist
Andrew Nicols

Bug Description

I've been having a look at bug #844604. Rather than re-inventing the wheel every time we want to do a CLI system, I propose that we create a CLI library
lib/cli.php

This should ideally give functionality for:
* retrieve arguments supplied on the CLI (e.g. --agree-to-license=yes --upgrade-only -p=letmein -<email address hidden>)
* add a log_exit or equivelant which would exit with the appropriate exit code (0 = success, 127 = error, other supplied ints in range) and exit - e.g. cli_exit().

Tags: cli library
Revision history for this message
Andrew Nicols (dobedobedoh) wrote :

I've been pondering whether the log_exit should go with the other error functions (e.g. log_debug) in lib/errors.php.
We currently have no log_die, and I doubt we want one except for CLI stuff (correct me if I'm wrong). Setting the exit code is very CLI specific. Therefore I've been toying with a function
  function cli_exit($message, $error = false)

Changed in mahara:
status: New → In Progress
importance: Undecided → Wishlist
assignee: nobody → Andrew Nicols (dobedobedoh)
milestone: none → 1.5.0
Revision history for this message
Andrew Nicols (dobedobedoh) wrote :
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/687
Committed: http://gitorious.org/mahara/mahara/commit/36f8803311a0c842d4cc8084c9567e12b4adadc0
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit 36f8803311a0c842d4cc8084c9567e12b4adadc0
Author: Andrew Robert Nicols <email address hidden>
Date: Tue Sep 13 08:58:12 2011 +0100

    Add CLI Library (Bug #844607)

    This commit adds a Command Line Interface to make writing CLI scripts
    easier. It can be called in a basic fashion, or an extended fashion which
    automatically generates help and applies verbosity, help, and argument
    validation.

    Change-Id: I9f13de74ba29e072e64e859f065bb6d754d6393b
    Signed-off-by: Andrew Robert Nicols <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

Hi Andrew,

Should we create a wiki page showing how to use these frameworks

Cheers,

Hugh

Revision history for this message
Melissa Draper (melissa) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 status fixreleased
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPjrYkAAoJECXBtiziiXdcBjUH+gOs1qGQ20HFISw5maAWKxaU
yT4JUSRYzcVk8g5FgnONKIDVMKo9ZiyZD0xTWoevwRamE5IiE00ltsoxtaVecvBx
Km/hOBIiaTCfNlZ/nCULO+FUflYWhuzjb8szGQNCLTJLXzHq1Q/BRJAWPzKvUweo
zKe23pNiXtMlRkqEs+IwWnf04M3YH8O6tqcoirtLWPmLRJxtW19qT5LOGdkFojVP
ode3BhogyPMFWxS9mhn0AgE9j/GdNMXbPxKCSqLhrcDCQvC+wXNqvWC/Fp7jMe0n
5mPXBmBPLCiQAIQ7a9GNV/71GhLEB6YkZ1HZj+EkCuXvdejKe/MutEVgHIiZUus=
=Yjja
-----END PGP SIGNATURE-----

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.