From 7b05d404a16526976f6e144c29f40a8881db19e1 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Fri, 1 Feb 2008 19:14:29 -0800 Subject: support quiet mode for type validation --- scripts/VyattaTypeChecker.pm | 7 ++++--- scripts/vyatta-validate-type.pl | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/VyattaTypeChecker.pm b/scripts/VyattaTypeChecker.pm index 451be52..902c278 100644 --- a/scripts/VyattaTypeChecker.pm +++ b/scripts/VyattaTypeChecker.pm @@ -142,16 +142,17 @@ sub validate_ipv6 { } sub validateType { - my ($type, $value) = @_; + my ($type, $value, $quiet) = @_; if (!defined($type) || !defined($value)) { return 0; } if (!defined($type_handler{$type})) { - print "type \"$type\" not defined\n"; + print "type \"$type\" not defined\n" if (!defined($quiet)); return 0; } if (!&{$type_handler{$type}}($value)) { - print "\"$value\" is not a valid value of type \"$type\"\n"; + print "\"$value\" is not a valid value of type \"$type\"\n" + if (!defined($quiet)); return 0; } diff --git a/scripts/vyatta-validate-type.pl b/scripts/vyatta-validate-type.pl index 318572c..64b7e8a 100755 --- a/scripts/vyatta-validate-type.pl +++ b/scripts/vyatta-validate-type.pl @@ -5,11 +5,17 @@ use lib "/opt/vyatta/share/perl5/"; use VyattaTypeChecker; # validate a value of a specific type -if ($#ARGV != 1) { - print "usage: vyatta-validate-type.pl \n"; +if ($#ARGV < 1) { + print "usage: vyatta-validate-type.pl [-q] \n"; exit 1; } -exit 0 if (VyattaTypeChecker::validateType($ARGV[0], $ARGV[1])); +my $quiet = undef; +if ($ARGV[0] eq '-q') { + shift; + $quiet = 1; +} + +exit 0 if (VyattaTypeChecker::validateType($ARGV[0], $ARGV[1], $quiet)); exit 1; -- cgit v1.2.3