Author: pebender
Date: Wed Sep 3 06:05:04 2008
New Revision: 3694
Modified:
trunk/gar-minimyth/html/minimyth/document-changelog.txt
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_command
Log:
Converted mm_command to perl.
Modified: trunk/gar-minimyth/html/minimyth/document-changelog.txt
==============================================================================
--- trunk/gar-minimyth/html/minimyth/document-changelog.txt (original)
+++ trunk/gar-minimyth/html/minimyth/document-changelog.txt Wed Sep 3
06:05:04 2008
@@ -1,7 +1,7 @@
MiniMyth Changelog
--------------------------------------------------------------------------------
-Changes since 57 (2008-09-02):
+Changes since 57 (2008-09-03):
Current MythTV versions
MythTV 0.21: version 0.21.0, release-0-21-fixes branch svn 18228.
@@ -10,11 +10,18 @@
Converted to perl from sh
- Added MiniMyth perl package.
- Implements the functions in /etc/rc.d/functions.
+ - 'mm_*' maps to 'MiniMyth::*' execpt for 'mm_mythdb_*_dump'
+ which maps to 'MiniMyth::mythdb_*_print'
+ - Function arguments differ because perl supports types other
than
+ strings.
+ - Function return mechanism differs because perl support
+ non-integer return values.
- Added perl init scripts.
- sh init scripts are the default.
- perl init scripts can be enabled by adding MM_INIT_TYPE=perl to
the
boot line.
- Converted the following mm_* scripts to perl:
+ mm_command
mm_game_exit
mm_game_start
mm_term_exit
Modified:
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_command
==============================================================================
---
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_command
(original)
+++
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_command
Wed Sep 3 06:05:04 2008
@@ -1,49 +1,101 @@
-#!/bin/sh
+#!/usr/bin/perl
-. /etc/rc.d/functions
+use strict;
+use warnings;
+use feature "switch";
+
+require MiniMyth;
+
+my $minimyth = new MiniMyth;
+$minimyth->var_load();
+
+sub output
+{
+ my $level = shift;
+ my $value = shift;
+ my $key = shift;
+
+ if (defined($value))
+ {
+ given (ref($value))
+ {
+ when (/^$/)
+ {
+ print ' ' x (4 * $level);
+ if (defined($key))
+ {
+ print "$key => ";
+ }
+ print "$value";
+ print "\n";
+ }
+ when (/^ARRAY$/)
+ {
+ if (defined($key))
+ {
+ print ' ' x (4 * $level);
+ print "$key => ";
+ }
+ print ' ' x (4 * $level);
+ print '[';
+ print "\n";
+ foreach (@{$value})
+ {
+ output($level + 1, $_);
+ }
+ print ' ' x (4 * $level);
+ print ']';
+ print "\n";
+ }
+ when (/^HASH$/)
+ {
+ if (defined($key))
+ {
+ print ' ' x (4 * $level);
+ print "$key => ";
+ }
+ print ' ' x (4 * $level);
+ print '{';
+ print "\n";
+ foreach (sort(keys(%{$value})))
+ {
+ output($level + 1, $value->{$_}, $_);
+ }
+ print ' ' x (4 * $level);
+ print '}';
+ print "\n";
+ }
+ }
+ }
+}
-commandlist=`/bin/cat /etc/rc.d/functions | /bin/grep '^mm_[^ ]*()' |
/bin/sed 's%([^ ]*)\(\).*%\1%' | /bin/sed 's%^mm_%%' | /usr/bin/sort`
+sub usage
+{
-usage() {
+ my @usage = ();
- local command
+ push(@usage, "");
+ push(@usage, "usage:");
+ push(@usage, " mm_command command [command_args ...]");
+ push(@usage, "");
+ push(@usage, " were 'command' is one of the MiniMyth perl package
methods");
+ push(@usage, " and 'command_args' are the arguments for that perl
package method.");
+ push(@usage, " Only MiniMyth perl package methods that have integer
and string");
+ push(@usage, " arguments will work correctly");
+ push(@usage, "");
- /bin/echo "usage:"
- /bin/echo " mm_command command [command_args ...]"
- /bin/echo ""
- /bin/echo " were 'command' is one of the following commands:"
- for command in ${commandlist} ; do
- /bin/echo " ${command}"
- done
- /bin/echo " and 'command_args' are the args for 'command'."
+ return [EMAIL PROTECTED];
}
-# valid if the first argument is a command.
-valid=0
-for command in ${commandlist} ; do
- if /usr/bin/test "${command}" = "$1" ; then
- valid=1
- fi
-done
-if /usr/bin/test ${valid} -eq 0 ; then
- usage
- exit 1
-fi
-
-IFS="~"
-
-command=
-arglist=
-for arg in $@ ; do
- if /usr/bin/test -z "${command}" ; then
- command=${arg}
- else
- if /usr/bin/test -z "${arglist}" ; then
- arglist="${arg}"
- else
- arglist="${arglist}${IFS}${arg}"
- fi
- fi
-done
+my $command = shift;
+
+if ((! defined($command)) || (! $command))
+{
+ die join("\n", @{usage()}) . "\n";
+}
+
+my $result = $minimyth->$command(@ARGV);
+
+output(0, $result);
-mm_${command} ${arglist}
+1;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"minimyth-commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/minimyth-commits?hl=en
-~----------~----~----~----~------~----~------~--~---