summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2008-02-01 19:14:29 -0800
committerAn-Cheng Huang <ancheng@vyatta.com>2008-02-01 19:14:29 -0800
commit7b05d404a16526976f6e144c29f40a8881db19e1 (patch)
tree3f8ce2fc1ee6274f44ab5204ad9969f1ed51a547
parent86d0c6a382fc494c2dda0a95ef84780d368cc40d (diff)
downloadvyatta-cfg-7b05d404a16526976f6e144c29f40a8881db19e1.tar.gz
vyatta-cfg-7b05d404a16526976f6e144c29f40a8881db19e1.zip
support quiet mode for type validation
-rw-r--r--scripts/VyattaTypeChecker.pm7
-rwxr-xr-xscripts/vyatta-validate-type.pl12
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 <type> <value>\n";
+if ($#ARGV < 1) {
+ print "usage: vyatta-validate-type.pl [-q] <type> <value>\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;