safedb 0.4.1002 → 0.5.1001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +35 -23
  3. data/README.md +69 -29
  4. data/lib/cli.rb +28 -22
  5. data/lib/controller/admin/access.rb +1 -1
  6. data/lib/controller/admin/commit.rb +53 -0
  7. data/lib/controller/admin/diff.rb +23 -25
  8. data/lib/controller/admin/export.rb +9 -11
  9. data/lib/controller/admin/goto.rb +2 -3
  10. data/lib/controller/admin/import.rb +5 -7
  11. data/lib/controller/admin/login.rb +16 -2
  12. data/lib/controller/admin/logout.rb +1 -1
  13. data/lib/controller/admin/open.rb +4 -5
  14. data/lib/controller/admin/refresh.rb +55 -0
  15. data/lib/controller/admin/token.rb +1 -1
  16. data/lib/controller/admin/use.rb +1 -1
  17. data/lib/controller/admin/view.rb +8 -10
  18. data/lib/controller/api/docker/docker.rb +1 -1
  19. data/lib/controller/api/jenkins/jenkins.rb +1 -1
  20. data/lib/controller/api/terraform/terraform.rb +7 -34
  21. data/lib/controller/api/vpn/vpn.rb +1 -1
  22. data/lib/controller/{usecase.rb → controller.rb} +15 -8
  23. data/lib/controller/edit/editverse.rb +2 -2
  24. data/lib/controller/id.rb +1 -1
  25. data/lib/controller/query/copy.rb +127 -0
  26. data/lib/controller/query/queryverse.rb +2 -2
  27. data/lib/controller/requirer.rb +1 -1
  28. data/lib/controller/set.rb +1 -1
  29. data/lib/controller/verse.rb +1 -1
  30. data/lib/controller/visit/visit.rb +1 -1
  31. data/lib/manual/copy-paste.md +13 -0
  32. data/lib/{controller/admin/tree.md → manual/dir-structure.md} +0 -0
  33. data/lib/manual/drag-drop.md +77 -0
  34. data/lib/manual/login-logout.md +46 -0
  35. data/lib/model/README.md +2 -2
  36. data/lib/model/book.rb +11 -6
  37. data/lib/model/indices.rb +1 -1
  38. data/lib/model/state.inspect.rb +67 -53
  39. data/lib/model/state.migrate.rb +19 -19
  40. data/lib/model/text_chunk.rb +35 -15
  41. data/lib/utils/clipboard/clip.rb +92 -0
  42. data/lib/utils/key.pass.rb +3 -1
  43. data/lib/version.rb +1 -1
  44. metadata +11 -7
  45. data/lib/controller/admin/checkin.rb +0 -83
  46. data/lib/controller/admin/checkout.rb +0 -57
  47. data/lib/modules/cryptology/collect.rb +0 -138
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module SafeDb
4
+
5
+ # The <b>refresh use case</b> commits any changes made to the safe book into
6
+ # master. This is straightforward if the master's state has not been forwarded
7
+ # by a ckeckin from another (shell) branch.
8
+ #
9
+ # == master and branch not in sync
10
+ #
11
+ # Commits cannot occur when the master's state has been moved forward by another
12
+ # branch commit. In these cases one needs to use the below sequence.
13
+ #
14
+ # - <tt>safe diff --refresh</tt> | diff will list what will the state changes during refresh
15
+ # - <tt>safe refresh</tt> | the actual merge down (from master to branch) that never deletes keys
16
+ # - <tt>safe commit</tt> | now the commit can proceed as the branch is in line with the master
17
+ #
18
+ # == refresh | merge up mechanics
19
+ #
20
+ # The mechanics of a simple in-sync refresh is to
21
+ #
22
+ # - sync the master crypts to exactly mimic the branch crypts
23
+ # - tell master the content id of the book index file
24
+ # - tell master what the current random iv (initialization vector) is
25
+ # - create a new commit ID and set it on both master and branch
26
+ # - set the master's last updated date and time
27
+ #
28
+ class Refresh < Controller
29
+
30
+
31
+ # The <b>refresh use case</b> commits any changes made to the safe book into
32
+ # master. This is straightforward if the master's state has not been forwarded
33
+ # by a ckeckin from another (shell) branch.
34
+ def execute
35
+
36
+ puts ""
37
+ puts " == Birth Day := #{@book.init_time()}\n"
38
+ puts " == Book Name := #{@book.book_name()} [#{@book.book_id}]\n"
39
+ puts " == Book Mark := #{@book.get_open_chapter_name()}/#{@book.get_open_verse_name()}\n" if @book.is_opened?()
40
+ puts ""
41
+
42
+ StateMigrate.refresh( @book )
43
+ StateMigrate.copy_commit_id_to_branch( @book )
44
+
45
+ puts "Refresh from master to branch was successful.\n"
46
+ puts ""
47
+
48
+
49
+ end
50
+
51
+
52
+ end
53
+
54
+
55
+ end
@@ -6,7 +6,7 @@ module SafeDb
6
6
  # to the workstation and shell environment. See the root README.md on how
7
7
  # to export it and create a simple command alias for it in the ~/.bash_aliases
8
8
  # script which is executed when the shell starts.
9
- class Token < UseCase
9
+ class Token < Controller
10
10
 
11
11
 
12
12
  def execute
@@ -16,7 +16,7 @@ module SafeDb
16
16
  # Error - if the domain name is not listed in the configuration file.
17
17
  # Error - if the (dictionary) path to the domain's base does not exist
18
18
  #
19
- class Use < UseCase
19
+ class Use < Controller
20
20
 
21
21
  attr_writer :domain_name
22
22
 
@@ -9,21 +9,19 @@ module SafeDb
9
9
  # Goto with the number effectively shortcuts the open pinpointer.
10
10
  # Show prints out the verse lines at the opened path but masks any secrets.
11
11
  # Tell also prints out the verse lines but unabashedly displays secrets.
12
- class View < UseCase
12
+ class View < Controller
13
13
 
14
14
  def execute
15
15
 
16
- book = Book.new()
17
-
18
16
  puts ""
19
- puts " == Birth Day := #{book.init_time()}\n"
20
- puts " == Book Name := #{book.book_name()} [#{book.book_id}]\n"
21
- puts " == Book Mark := #{book.get_open_chapter_name()}/#{book.get_open_verse_name()}\n" if book.is_opened?()
17
+ puts " == Birth Day := #{@book.init_time()}\n"
18
+ puts " == Book Name := #{@book.book_name()} [#{@book.book_id}]\n"
19
+ puts " == Book Mark := #{@book.get_open_chapter_name()}/#{@book.get_open_verse_name()}\n" if @book.is_opened?()
22
20
  puts ""
23
21
 
24
22
  verse_count = 0
25
23
  chapter_index = 0
26
- book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
24
+ @book.branch_chapter_keys().each_pair do | chapter_name, chapter_keys |
27
25
 
28
26
  chapter_index += 1
29
27
  verse_index = 0
@@ -32,9 +30,9 @@ module SafeDb
32
30
 
33
31
  verse_index += 1
34
32
  verse_count += 1
35
- is_open = book.is_open?( chapter_name, verse_name )
33
+ is_open = @book.is_open?( chapter_name, verse_name )
36
34
  isnt_first = verse_count != 1
37
- isnt_last = ( chapter_index != book.branch_chapter_keys().length() ) || ( verse_index != chapter_data.length() )
35
+ isnt_last = ( chapter_index != @book.branch_chapter_keys().length() ) || ( verse_index != chapter_data.length() )
38
36
  mark_open = is_open ? "<< " : ""
39
37
  mark_close = is_open ? " >>" : ""
40
38
  fixdint = format( "%02d", verse_count )
@@ -47,7 +45,7 @@ module SafeDb
47
45
  end
48
46
 
49
47
  puts ""
50
- puts " == There are #{book.branch_chapter_keys().length()} chapters and #{verse_count} verses."
48
+ puts " == There are #{@book.branch_chapter_keys().length()} chapters and #{verse_count} verses."
51
49
  puts ""
52
50
 
53
51
  return
@@ -7,7 +7,7 @@ module SafeDb
7
7
  # safe docker login
8
8
  # safe docker logout
9
9
 
10
- class Docker < UseCase
10
+ class Docker < Controller
11
11
 
12
12
  # The command which currently must be login, logout or
13
13
  # an empty string.
@@ -11,7 +11,7 @@ module SafeDb
11
11
  #
12
12
  # safe jenkins post <<[ aws | docker | git ]>> <<jenkins-host-url>>
13
13
 
14
- class Jenkins < UseCase
14
+ class Jenkins < Controller
15
15
 
16
16
  # The three instance variables provided through the command line like
17
17
  # for example $ safe jenkins post aws http://localhost:8080
@@ -14,7 +14,7 @@ module SafeDb
14
14
  # ubiquitous safe open command.
15
15
  #
16
16
  # safe open <<chapter>> <<verse>>
17
- class Terraform < UseCase
17
+ class Terraform < QueryVerse
18
18
 
19
19
  attr_writer :command
20
20
 
@@ -22,34 +22,7 @@ module SafeDb
22
22
  # and convert for consumption into module input variables.
23
23
  TERRAFORM_EVAR_PREFIX = "TF_VAR_"
24
24
 
25
- def execute
26
-
27
- return unless ops_key_exists?
28
- master_db = get_master_database()
29
- return if unopened_envelope?( master_db )
30
-
31
- # Get the open chapter identifier (id).
32
- # Decide whether chapter already exists.
33
- # Then get (or instantiate) the chapter's hash data structure
34
- chapter_id = ENVELOPE_KEY_PREFIX + master_db[ ENV_PATH ]
35
- verse_id = master_db[ KEY_PATH ]
36
- chapter_exists = KeyApi.db_envelope_exists?( master_db[ chapter_id ] )
37
-
38
-
39
- # -- @todo begin
40
- # -- Throw an exception (error) if the chapter
41
- # -- either exists and is empty or does not exist.
42
- # -- @todo end
43
-
44
-
45
- # Unlock the chapter data structure by supplying
46
- # key/value mini-dictionary breadcrumbs sitting
47
- # within the master database at the section labelled
48
- # envelope@<<actual_chapter_id>>.
49
- chapter_data = DataStore.from_json( Lock.content_unlock( master_db[ chapter_id ] ) )
50
-
51
- # Now read the three AWS IAM credentials @access.key, @secret.key and region.key
52
- # into the 3 environment variables terraform expects to find.
25
+ def query_verse()
53
26
 
54
27
  # ############## | ############################################################
55
28
  # @todo refactor | ############################################################
@@ -82,12 +55,11 @@ module SafeDb
82
55
  puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
83
56
  puts ""
84
57
 
85
- ENV[ "AWS_ACCESS_KEY_ID" ] = chapter_data[ verse_id ][ "@access.key" ]
86
- ENV[ "AWS_SECRET_ACCESS_KEY" ] = chapter_data[ verse_id ][ "@secret.key" ]
87
- ENV[ "AWS_DEFAULT_REGION" ] = chapter_data[ verse_id ][ "region.key" ]
58
+ ENV[ "AWS_ACCESS_KEY_ID" ] = @verse[ "@access.key" ]
59
+ ENV[ "AWS_SECRET_ACCESS_KEY" ] = @verse[ "@secret.key" ]
60
+ ENV[ "AWS_DEFAULT_REGION" ] = @verse[ "region.key" ]
88
61
 
89
- mini_dictionary = chapter_data[ verse_id ]
90
- mini_dictionary.each do | key_str, value_object |
62
+ @verse.each do | key_str, value_object |
91
63
 
92
64
  is_env_var = key_str.start_with?( ENV_VAR_PREFIX_A ) || key_str.start_with?( ENV_VAR_PREFIX_B )
93
65
  next unless is_env_var
@@ -97,6 +69,7 @@ module SafeDb
97
69
  env_var_keyname = TERRAFORM_EVAR_PREFIX + env_var_name
98
70
  ENV[ env_var_keyname ] = value_object
99
71
  puts "Environment variable #{env_var_keyname} has been set."
72
+ log.info(x) { "Setting terraform environment variable => #{env_var_keyname}" }
100
73
 
101
74
  end
102
75
 
@@ -7,7 +7,7 @@ module SafeDb
7
7
  #
8
8
  # safe vpn up
9
9
  # safe vpn down
10
- class Vpn < UseCase
10
+ class Vpn < Controller
11
11
 
12
12
  attr_writer :command
13
13
 
@@ -10,7 +10,7 @@ module SafeDb
10
10
  #
11
11
  # == Common Use Case Behaviour
12
12
  #
13
- # This {SafeDb::UseCase} use case is designed to be extended and does preparatory
13
+ # This {SafeDb::Controller} use case is designed to be extended and does preparatory
14
14
  # work to create favourable and useful conditions to make use cases readable,
15
15
  # less repetitive, simpler and concise.
16
16
  #
@@ -26,7 +26,7 @@ module SafeDb
26
26
  # - {stash} put directive key/value pair in default section
27
27
  # - {read} read the value at key_name from the parameter section
28
28
  # - {write} put directive key/value pair in parameter section
29
- class UseCase
29
+ class Controller
30
30
 
31
31
  # All controllers are initialized here meaning that there will be automatic
32
32
  # execution of very frequently used setup behaviour. This includes
@@ -37,12 +37,21 @@ module SafeDb
37
37
  class_name = self.class.name.split(":").last.downcase
38
38
  is_no_token_uc = [ "token", "init", "id" ].include? class_name
39
39
  return if is_no_token_uc
40
-
41
40
  exit(100) unless ops_key_exists?
42
41
 
43
- # Chop off all fact work for now. May need to resurrect for VPN functionality.
42
+ is_login_uc = class_name.eql?( "login" )
43
+ return if is_login_uc
44
+
45
+ not_logged_in = StateInspect.not_logged_in?()
46
+ puts TextChunk.not_logged_in_message() if not_logged_in
47
+ exit(100) if not_logged_in
48
+
49
+ @book = Book.new()
44
50
  return
45
51
 
52
+ =begin
53
+ Fact Functionality
54
+ ======================
46
55
  fact_filepath = File.sister_filepath( self, "ini", :execute )
47
56
  log.info(x) { "Search location for INI factfile is [#{fact_filepath}]" }
48
57
  return unless File.exists?( fact_filepath )
@@ -51,6 +60,7 @@ module SafeDb
51
60
  add_secret_facts @facts
52
61
  @facts.assimilate_ini_file( fact_filepath )
53
62
  @dictionary = @facts.f[ @facts.to_symbol( class_name ) ]
63
+ =end
54
64
 
55
65
  end
56
66
 
@@ -59,10 +69,7 @@ module SafeDb
59
69
  # data structures and indices.
60
70
  def read_verse()
61
71
 
62
- # @todo => consider doing the book index opening with initializer UNLESS token/admin use case
63
-
64
- @book = Book.new()
65
- return if @book.unopened_chapter_verse()
72
+ exit(100) if @book.unopened_chapter_verse?()
66
73
  @verse = @book.get_open_verse_data()
67
74
 
68
75
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SafeDb
4
4
 
5
- # Any {UseCase} class wishing to edit a safe verse can make use of the functionality
5
+ # Any {Controller} class wishing to edit a safe verse can make use of the functionality
6
6
  # in this parent by exposing an edit_verse() method.
7
7
  #
8
8
  # Classes extending this class will have access to
@@ -16,7 +16,7 @@ module SafeDb
16
16
  #
17
17
  # After the edit method completes the amended chapter data structure will be encrypted
18
18
  # and streamed to a ciphertext file.
19
- class EditVerse < UseCase
19
+ class EditVerse < Controller
20
20
 
21
21
  # This parental behaviour sets up common ubiquitous chapter and verse data structures
22
22
  # and indices. It then calls the child's query_verse() behaviour and once that is complete
data/lib/controller/id.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module SafeDb
4
4
 
5
5
 
6
- class Id < UseCase
6
+ class Id < Controller
7
7
 
8
8
 
9
9
  def execute
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module SafeDb
4
+
5
+ # The copy use case copies one or more chapters, one or more verses and
6
+ # one or more lines to the clipboard so Ctrl-v can be used outside the
7
+ # safe to paste data in (like complex passwords).
8
+ #
9
+ # Use {Drag} and {Drop} to move data between books, chapters, verses and
10
+ # lines.
11
+ #
12
+ # Visit documentation at https://www.safedb.net/docs/copy-paste
13
+ class Copy < QueryVerse
14
+
15
+ # this entity can point to a book, chapter, verse or line. If no
16
+ # parameter entity is provided, the --all switch must be present
17
+ # to avoid an error message.
18
+ attr_writer :entity
19
+
20
+ # The copy use case copies one or more chapters, one or more verses and
21
+ # one or more lines to the clipboard so Ctrl-v can be used outside the
22
+ # safe to paste data in (like complex passwords).
23
+ def query_verse()
24
+
25
+ print @verse[ @key_name ]
26
+
27
+ =begin
28
+
29
+ From xclip man page
30
+
31
+ EXAMPLES
32
+ I hate man pages without examples!
33
+
34
+ uptime | xclip
35
+
36
+ Put your uptime in the X selection. Then middle click in an X application to paste.
37
+
38
+ xclip -loops 10 -verbose /etc/motd
39
+
40
+ Exit after /etc/motd (message of the day) has been pasted 10 times. Show how many selection requests (pastes)
41
+ have been processed.
42
+
43
+ xclip -o > helloworld.c
44
+
45
+ Put the contents of the selection into a file.
46
+
47
+ xclip -t text/html index.html
48
+
49
+ Middle click in an X application supporting HTML to paste the contents of the given file as HTML.
50
+
51
+
52
+
53
+ 78apollo@unity:~$ xclip -o
54
+ Constant Summaryapollo@unity:~$
55
+ apollo@unity:~$ xclip -o; echo
56
+ Constant Summary
57
+ apollo@unity:~$ xclip -o; echo
58
+ Module: Clipboard::File
59
+ apollo@unity:~$ xclip -o; echo
60
+ character of the selection specified
61
+ apollo@unity:~$ xclip -o; echo
62
+ long as they remain unambiguous
63
+ apollo@unity:~$ xclip -o; echo
64
+ long as they remain unambiguous
65
+ apollo@unity:~$ xclip -o; echo
66
+ long as they remain unambiguous
67
+ apollo@unity:~$ xclip -i ''
68
+ xclip: : No such file or directory
69
+ apollo@unity:~$ xclip -o; echo
70
+ long as they remain unambiguous
71
+ apollo@unity:~$ xclip ''
72
+ xclip: : No such file or directory
73
+ apollo@unity:~$ xclip -o; echo
74
+ long as they remain unambiguous
75
+ apollo@unity:~$ xclip -t ''
76
+ q
77
+ adsf
78
+ 
79
+
80
+ apollo@unity:~$
81
+ apollo@unity:~$
82
+ apollo@unity:~$ uptime | xclip
83
+ apollo@unity:~$ xclip -o; echo
84
+ 00:34:46 up 5:10, 1 user, load average: 0.47, 0.52, 0.35
85
+
86
+ apollo@unity:~$ uptime
87
+ 00:35:05 up 5:11, 1 user, load average: 0.34, 0.48, 0.34
88
+ apollo@unity:~$ uptime | xclip
89
+ apollo@unity:~$ xclip -o
90
+ 00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
91
+ apollo@unity:~$ xclip -o
92
+ 00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
93
+ apollo@unity:~$ xclip -o
94
+ 00:35:29 up 5:11, 1 user, load average: 0.22, 0.44, 0.33
95
+ apollo@unity:~$ xclip -o
96
+ Error: target STRING not available
97
+ apollo@unity:~$ xclip -o
98
+ Error: target STRING not available
99
+ apollo@unity:~$ xclip -o
100
+ Error: target STRING not available
101
+ apollo@unity:~$ xclip -o
102
+ apollo@unity:~$
103
+ apollo@unity:~$ xclip -o; echo
104
+
105
+ apollo@unity:~$ xclip -o; echo
106
+ instead of -display. However, -v couldn't be used because it is ambiguous (it could be short for -verbose or
107
+ apollo@unity:~$ xclip -o; echo
108
+ 0345 072 5555
109
+ apollo@unity:~$ echo "safe deleted clipboard contents" | xclip
110
+ apollo@unity:~$ xclip -o; echo
111
+ safe deleted clipboard contents
112
+
113
+ apollo@unity:~$ xclip -o; echo
114
+ (traditionally with the middle mouse button
115
+ apollo@unity:~$ xclip -o; echo
116
+ safedb.yijx-r7zr.19093.1515.01.676152709.json
117
+
118
+ =end
119
+
120
+
121
+ end
122
+
123
+
124
+ end
125
+
126
+
127
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SafeDb
4
4
 
5
- # Any {UseCase} class wishing to query a safe verse can make use of the functionality
5
+ # Any {Controller} class wishing to query a safe verse can make use of the functionality
6
6
  # in this parent by exposing an query_verse() method.
7
7
  #
8
8
  # Classes extending this class will have access to
@@ -16,7 +16,7 @@ module SafeDb
16
16
  #
17
17
  # The query_verse() method is not succeeded by any behaviour in the parent. Chilc classes
18
18
  # must do their own output management.
19
- class QueryVerse < UseCase
19
+ class QueryVerse < Controller
20
20
 
21
21
  # This parental behaviour sets up common ubiquitous chapter and verse data structures
22
22
  # and indices.
@@ -86,7 +86,7 @@ module SafeDb
86
86
  def self.gems( gem_filepath )
87
87
 
88
88
  require_relative "../version"
89
- require_relative "../controller/usecase"
89
+ require_relative "../controller/controller"
90
90
  require_relative "../controller/admin/access"
91
91
  require_relative "../controller/edit/editverse"
92
92
  require_relative "../controller/query/queryverse"
@@ -13,7 +13,7 @@ module SafeDb
13
13
  # The configuration directive will either be created or overwriten within the
14
14
  # book's configuration store.
15
15
  #
16
- class Set < UseCase
16
+ class Set < Controller
17
17
 
18
18
  attr_writer :directive_name, :directive_value
19
19
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SafeDb
4
4
 
5
- class Verse < UseCase
5
+ class Verse < Controller
6
6
 
7
7
  def execute
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SafeDb
4
4
 
5
- class Visit < UseCase
5
+ class Visit < Controller
6
6
 
7
7
  def execute
8
8
 
@@ -0,0 +1,13 @@
1
+
2
+ # safe copy | safe paste
3
+
4
+ <tt>Copy and paste data to and from the **clipboard**</tt>.
5
+
6
+ ## pre-condition - install xclip
7
+
8
+ Linux uses xclip to manage the clipboard so we need to install it before using safe's copy and paste functions.
9
+
10
+ ```
11
+ sudo apt install xclip
12
+ ```
13
+
@@ -0,0 +1,77 @@
1
+
2
+ # safe drag | safe drop
3
+
4
+ <tt>safe drag</tt> picks up data from one place and <tt>safe drop</tt> places that data elsewhere.
5
+
6
+ ## On the same level
7
+
8
+ You can only drop data when you are at the same level as when you picked it up (although not necessarily in the same book).
9
+
10
+ ### Verse Level
11
+
12
+ This example drags a key/value pair from one verse to another in the same book.
13
+
14
+ ```
15
+ safe open <<chapter.x>> <<verse.x>>
16
+ safe drag <<line>>
17
+ safe open <<chapter.y>> <<verse.y>>
18
+ safe drop
19
+ ```
20
+
21
+ ## Different Books
22
+
23
+ You can use drag and drop to take data from one book and drop it into another. The rules about being on the same level still apply.
24
+
25
+ ### Drag line to another book
26
+
27
+ Samantha is not just a cousin, she was in the same class in 2010. I want to copy her phone number from my family book to my friends book.
28
+
29
+ ```
30
+ safe login friends
31
+ safe login family
32
+ safe open cousins samantha
33
+ safe drag phone.number
34
+ safe use friends
35
+ safe open class-of-2010 samantha
36
+ safe drop
37
+ safe logout --all
38
+ ```
39
+
40
+ If the phone number existed it will be overwritten. If not it will be created.
41
+
42
+ ## Dragging more than one
43
+
44
+ The <tt>--all</tt> switch can be used to drag a collective.
45
+
46
+ You can either drag a single line, verse or chapter, or you can drag
47
+
48
+ - every line in a verse
49
+ - every verse in a chapter
50
+ - every chapter in a book
51
+
52
+ ## All siblings are invited to the wedding
53
+
54
+ This example copies all (verse) siblings to the wedding-guests chapter.
55
+
56
+ ```
57
+ safe open siblings
58
+ safe drag --all
59
+ safe open wedding-guests
60
+ safe drop
61
+ ```
62
+
63
+ ## Renaming when you drop
64
+
65
+ What if you want to rename the line, verse or chapter being dragged and dropped. You can! As long as you are not dragging multiples (using --all).
66
+
67
+ You can use the data in one verse as a starting point for another.
68
+
69
+ ```
70
+ safe open contacts
71
+ safe drag peter
72
+ safe drop paul
73
+ ```
74
+
75
+ The paul verse is created with the same lines as peter has.
76
+
77
+ If a paul verse already existed the data within it is merged with priority (on conflicts) given to the (incoming) data being dropped.
@@ -0,0 +1,46 @@
1
+
2
+ # safe login | safe logout
3
+
4
+ You can login to one or more books at a shell command line.
5
+
6
+ ```
7
+ safe login <<book>>
8
+ safe login <<book>> --password=<<password>>
9
+ safe login <<book>> -p <<password>>
10
+ safe login <<book>> --clip
11
+ safe login <<book>> -c
12
+ ```
13
+
14
+ ## Password Conventions
15
+
16
+ The safe will **search for passwords** in an orderly manner as per the conventions below.
17
+
18
+ | # | Location | Description (and Important Points) | Example |
19
+ |:---:|:---------- |:------------------------------ |:----------------------- |
20
+ | 1 | Command Line | Leave **a space** before the <tt>safe init</tt> or <tt>safe login</tt> commands to avoid the command being written into `.bash_history` - do not use if AN Other can run `ps` on your machine. | <tt>safe login contacts --password=secret123</tt> |
21
+ | 2 | Environment Variable | First export the password into an environment variable called SAFE_BOOK_PASSWORD and then issue a login. Don't forget to **leave a space** before the <tt>export</tt> command to avoid being logged into .bash_history | <tt>safe login contacts</tt> |
22
+ | 3 | Environment Variables | If you want to login to multiple books in the same shell (or within scripts) you can export the environment variable with the book name appended. | **export SAFE_BOOK_PASSWORD_contacts=secret123** and **export SAFE_BOOK_PASSWORD_accounts=p455w0rd** |
23
+ | 4 | **clip board** | A <tt>--clip</tt> switch **(or -c)** appended to the init and/or login commands tells safe to read the password from the clip board and then immediately delete the clip board contents. | safe login contacts --clip |
24
+ | 5 | Prompt | The ubiquitous password prompt will be issued if none of the above options are viable. | safe login contacts |
25
+
26
+ <!--
27
+ | 3 | xxx | xxxx | xxx |
28
+ -->
29
+
30
+ ### login pre-conditions
31
+
32
+ To login into a safe book you must
33
+
34
+ - have installed safe and set the token (env var)
35
+ - (either) have initialized the book using safe init
36
+ - (or) have pulled in a safe database using safe clone
37
+ - know the book's name and password (from safe init)
38
+
39
+ ## Related Commands
40
+
41
+ | safe command | parameters | observable value delivered | relationships |
42
+ |:------------ |:---------- |:------------------------------------------------------ |:----------------------- |
43
+ | safe init | book name | creates the book for managing credentials | book must exist first |
44
+ | safe use | book name | switch books after same shell logins to multiple books | login must have occured |
45
+ | safe logout | (none) | deletes session information preventing further usage | can logout after login |
46
+
data/lib/model/README.md CHANGED
@@ -7,8 +7,8 @@ The need to cycle content occurs during
7
7
 
8
8
  - <tt>initialization</tt> - a new master state box is created
9
9
  - <tt>login</tt> - branch state is created that mirrors master
10
- - <tt>checkin</tt> - transfers state from branch to master
11
- - <tt>checkout</tt> - transfers state from master to branch
10
+ - <tt>commit</tt> - transfers state from branch to master
11
+ - <tt>refresh</tt> - transfers state from master to branch
12
12
 
13
13
 
14
14
  ## State Elements Transition Table