diff options
| author | wr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b> | 2006-01-22 00:42:57 +0000 |
|---|---|---|
| committer | wr61 <wr61@e10066b5-e1e2-0310-b819-94efdf66514b> | 2006-01-22 00:42:57 +0000 |
| commit | df8e71908273ec2bb645ef96d0b76775d1d6a164 (patch) | |
| tree | 07eebe18ba0f6eb473c6248a634aa1223f5594a7 | |
| parent | 851f22f58f4a02c84186070a792648598fac363c (diff) | |
| download | vdr-plugin-muggle-df8e71908273ec2bb645ef96d0b76775d1d6a164.tar.gz vdr-plugin-muggle-df8e71908273ec2bb645ef96d0b76775d1d6a164.tar.bz2 | |
better error messages for mugglei when called incorrectly
put myself into the copyright message of mugglei
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@911 e10066b5-e1e2-0310-b819-94efdf66514b
| -rw-r--r-- | mg_setup.c | 2 | ||||
| -rw-r--r-- | mugglei.c | 37 |
2 files changed, 22 insertions, 17 deletions
@@ -215,6 +215,8 @@ bool mgSetup::ProcessArguments (int argc, char *argv[]) CreateMode = true; } break; + case '?': + return false; } } return true; @@ -80,15 +80,12 @@ path_within_tld() return !strncmp(path,the_setup.ToplevelDir,tldlen); } -int main( int argc, char *argv[] ) + +static void +usage() { - the_setup.SetMugglei(); - mgSetDebugLevel(1); - - if( argc < 2 ) - { // we need at least a filename! std::cout << "mugglei -- import helper for Muggle VDR plugin" << std::endl; - std::cout << "(C) Lars von Wedel" << std::endl; + std::cout << "(C) Lars von Wedel, Wolfgang Rohdewald" << std::endl; std::cout << "This is free software; see the source for copying conditions." << std::endl; std::cout << "" << std::endl; std::cout << "Usage: mugglei [OPTION]... [FILE]..." << std::endl; @@ -101,9 +98,18 @@ int main( int argc, char *argv[] ) std::cout << the_setup.HelpText(); exit( 2 ); - } +} + +int main( int argc, char *argv[] ) +{ + the_setup.SetMugglei(); + mgSetDebugLevel(1); + + if( argc < 2 ) + usage(); - the_setup.ProcessArguments(argc,argv); + if (!the_setup.ProcessArguments(argc,argv)) + usage(); if (!path_within_tld()) { @@ -111,13 +117,10 @@ int main( int argc, char *argv[] ) << " or below" << std::endl; exit( 2 ); } - if (optind<argc) - { - mgDb *sync = GenerateDB(); - sync->Sync(argv+optind); - delete sync; - delete DbServer; - } - return 0; + if (optind==argc) + usage(); + mgDb *sync = GenerateDB(); + sync->Sync(argv+optind); + delete sync; } |
