aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/mpan64
1 files changed, 32 insertions, 32 deletions
diff --git a/scripts/mpan b/scripts/mpan
index 76660412..54ce701e 100755
--- a/scripts/mpan
+++ b/scripts/mpan
@@ -19,26 +19,48 @@
# You should have received a copy of the GNU General Public License
# along with ManaTools. If not, see <http://www.gnu.org/licenses/>.
+package mpan::CommandLine;
+
+use Moose;
+extends 'ManaTools::Shared::GUI::CommandLine';
+
+use ManaTools::Shared::Locales;
+
+my $loc = ManaTools::Shared::Locales->new();
+
+has 'devel' => (
+ is => 'ro',
+ isa => 'Bool',
+ documentation => $loc->N('Developers mode'),
+);
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+
+1;
+
use strict;
use warnings;
use diagnostics;
use ManaTools::Privileges;
use ManaTools::SettingsReader;
use ManaTools::MainDisplay;
-use yui;
+use mpan::CommandLine;
-my $cmdline = new yui::YCommandLine;
+use yui;
-usage() if $cmdline->find("--help") > 0 || $cmdline->find("-h") > 0;
+my $cmdline = mpan::CommandLine->new_with_options();
my $settings = getSettings();
-if ($cmdline->find("--dev") > 0) {
- print "== Development mode ON\n";
+if ($cmdline->devel() > 0) {
+ print $loc->N("== Development mode ON ==") . "\n";
}
else {
ask_for_authentication($settings->{priv_method}) if is_root_capability_required();
}
+
my $mainWin = new ManaTools::MainDisplay();
while (1) {
my $launch = $mainWin->start();
@@ -55,37 +77,15 @@ while (1) {
}
-sub usage {
- print "\n";
- print "Usage mpan [options...]\n\n";
- print "Options:\n";
- print "\t--help | -h print this help\n";
-## anaselli: --name now is used only to add a path to /etc (e.g. --name mcc2 means /etc/mcc2)
- # and it is overriden by --conf_dir, so it should be discussed better to understand
- # if it is really needed any more.
- # Window title is got from settings.conf (key title)
- print "\t--name string specify the window title of the mana-tools panel\n";
- print "\t--conf_dir path specify the settings.conf file directory\n";
- print "\n";
- exit(0);
-}
-
-# adpanel settings
+# mpan settings
sub getSettings {
my ($self) = @_;
- my $confDir = "/etc/mpan";
# yui commandline parser
- my $pos = $cmdline->find("--conf_dir");
- if ($pos > 0) {
- $confDir = $cmdline->arg($pos + 1);
- }
- else {
- $pos = $cmdline->find("--name");
- if ($pos > 0) {
- $confDir = "/etc/" . $cmdline->arg($pos+1);
- }
- }
+ my $confDir = $cmdline->conf_dir() || "/etc";
+ chop $confDir if substr($confDir, -1) eq '/';
+ $confDir .= '/mpan';
+
# configuration file name
my $fileName = "$confDir/settings.conf";
return new ManaTools::SettingsReader($fileName);