marhan_cli 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,3 +19,7 @@
19
19
  **my-net-ip** renamed to **web:my-ip**
20
20
  **add-ssh-key** renamed to **net:add-ssh-key**
21
21
 
22
+ ## v0.0.6
23
+
24
+ * TrueCrypt command added.
25
+ * Mount and unmount commands for private hard disk added.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # MarhanCli
1
+ # MarhanCli [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/marhan/marhan_cli)
2
2
 
3
- This gem is a toolset my my own needs.
3
+ This gem is a console tool for my own needs.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,9 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Ater installation of the gem type `mcli` to get a list of possible commands
22
+
23
+ $ mcli
22
24
 
23
25
  ## Contributing
24
26
 
@@ -0,0 +1,20 @@
1
+ require 'marhan_cli/helper/constraint'
2
+
3
+ module MarhanCli
4
+ class TrueCryptApp
5
+
6
+ def initialize()
7
+ @binary = "/Applications/TrueCrypt.app/Contents/MacOS/TrueCrypt"
8
+ raise ArgumentError, "No installation of TrueCrypt found!" unless File.exist? @binary
9
+ end
10
+
11
+ def mount_command()
12
+ "#{@binary} --mount /dev/rdisk1s2 /Volumes/enc1"
13
+ end
14
+
15
+ def unmount_command()
16
+ "#{@binary} -d /Volumes/enc1"
17
+ end
18
+
19
+ end
20
+ end
@@ -5,5 +5,12 @@ module MarhanCli
5
5
  class Command < Thor
6
6
  include Thor::Actions
7
7
 
8
+ protected
9
+
10
+ def exit_command(message)
11
+ say message, :red
12
+ exit(1)
13
+ end
14
+
8
15
  end
9
16
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'marhan_cli/server/remote_machine'
2
+ require 'marhan_cli/network/remote_machine'
3
3
  require 'marhan_cli/command'
4
4
 
5
5
  module MarhanCli
@@ -32,23 +32,30 @@ module MarhanCli
32
32
  :desc => "Path of id file"
33
33
 
34
34
  def add_ssh_key
35
- host = options[:host] || get_option(:host)
36
- user = options[:user] || get_option(:user)
37
- password = options[:password] || get_option(:password)
38
- id_file = options[:file]
39
- port = options[:port]
35
+ host = get_or_ask(:host)
36
+ user = get_or_ask(:user)
37
+ password = get_or_ask(:password)
38
+ id_file = get(:file)
39
+ port = get(:port)
40
40
 
41
41
  remote_machine = RemoteMachine.new(host, port)
42
42
  remote_machine.add_id_to_authorized_keys(user, password, id_file)
43
43
  say "successfully copied #{id_file} to #{host}", :green
44
44
  rescue Exception => e
45
- say "copying of id file to remote machine failed: #{e}", :red
46
- exit(1)
45
+ exit_command("copying of id file to remote machine failed: #{e}")
47
46
  end
48
47
 
49
48
  protected
50
49
 
51
- def get_option(option)
50
+ def get(option_name)
51
+ options[option_name]
52
+ end
53
+
54
+ def get_or_ask(option_name)
55
+ options[option_name] || ask_for_option(:host)
56
+ end
57
+
58
+ def ask_for_option(option)
52
59
  value = ask("Please enter #{option}:")
53
60
  raise Thor::Error, "You must enter a value for that field." if value.empty?
54
61
  value
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'marhan_cli/command'
3
+ require 'marhan_cli/app/true_crypt_app'
4
+
5
+ module MarhanCli
6
+ class TrueCrypt < MarhanCli::Command
7
+
8
+ namespace :crypt
9
+
10
+ desc "crypt:mount", "Mounts encrypted disk with TrueCrypt"
11
+
12
+ def mount
13
+ begin
14
+ @app = TrueCryptApp.new
15
+ run @app.mount_command
16
+ say "finished", :green
17
+ rescue Exception => e
18
+ exit_command("Failed: #{e}")
19
+ end
20
+ end
21
+
22
+ desc "crypt:unmount", "Unmounts encrypted disk with TrueCrypt"
23
+
24
+ def unmount
25
+ begin
26
+ @app = TrueCryptApp.new
27
+ run @app.unmount_command
28
+ say "finished", :green
29
+ rescue Exception => e
30
+ exit_command("Failed: #{e}")
31
+ end
32
+ end
33
+
34
+ end
35
+ end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module MarhanCli
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marhan_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -59,12 +59,14 @@ files:
59
59
  - Rakefile
60
60
  - bin/mcli
61
61
  - lib/marhan_cli.rb
62
+ - lib/marhan_cli/app/true_crypt_app.rb
62
63
  - lib/marhan_cli/command.rb
63
64
  - lib/marhan_cli/commands/network.rb
65
+ - lib/marhan_cli/commands/true_crypt.rb
64
66
  - lib/marhan_cli/commands/web.rb
65
67
  - lib/marhan_cli/helper/constraint.rb
66
- - lib/marhan_cli/server/errors.rb
67
- - lib/marhan_cli/server/remote_machine.rb
68
+ - lib/marhan_cli/network/errors.rb
69
+ - lib/marhan_cli/network/remote_machine.rb
68
70
  - lib/marhan_cli/version.rb
69
71
  - marhan_cli.gemspec
70
72
  homepage: https://github.com/marhan/marhan_cli