Browse Source

Start some work on sshfs-helper

Samuel W. Flint 5 years ago
parent
commit
bd05c3cf3d
1 changed files with 17 additions and 20 deletions
  1. 17 20
      sshfs-helper

+ 17 - 20
sshfs-helper

@@ -2,25 +2,20 @@
 
 use strict;
 use warnings;
-use YAML qw(LoadFile DumpFile);
+# use YAML qw(LoadFile DumpFile);
+use YAML::Tiny;
 
 my $configFile = "$ENV{HOME}/.sshfs-helper";
-
+my $yaml
 my $configData;
 
 if ((not -e $configFile)) {
-    $configData = {};
-    DumpFile($configFile, $configData);
+    YAML::Tiny->new({})->write($configFile);
+    print "Create Config file, exiting."
+    exit 1;
 } else {
-     $configData = LoadFile($configFile);
-}
-
-sub addConfig {
-    
-}
-
-sub changeConfig {
-    
+    $yaml = YAML::Tiny->read($configFile);
+    $configData = $yaml->[0];
 }
 
 sub mount {
@@ -38,7 +33,7 @@ sub list {
 }
 
 sub usage {
-    print "sshfs-helper [ add | list | edit name | mount name | unmount name | help ]\n";
+    print "sshfs-helper [ list | mount name | unmount name | help ]\n";
 }
 
 sub help {
@@ -56,17 +51,19 @@ if (@ARGV == 0) {
 my $command = shift @ARGV;
 my @arguments = @ARGV;
 
-if ($command eq "add") {
-    addConfig(@arguments);
-} elsif ($command eq "list") {
-    list();
-} elsif ($command eq "edit") {
+if ($command eq "list") {
+    list;
 } elsif ($command eq "mount") {
+    mount shift @arguments;
 } elsif ($command eq "unmount") {
+    unmount shift @arguments;
 } elsif ($command eq "help") {
+    help;
+    exit 1;
 } else {
     usage();
     exit 1;
 }
 
-DumpFile($configFile, $configData);
+$yaml->write($configFile);
+# DumpFile($configFile, $configData);