hsume2-aka 0.3.2 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/bin/aka +18 -0
  4. data/bin/build +37 -0
  5. data/bin/postinstall +3 -0
  6. data/bin/postremove +3 -0
  7. data/lib/aka/configuration.pb.rb +41 -0
  8. data/lib/aka/configuration.proto +20 -0
  9. data/lib/aka/link_manager.rb +30 -0
  10. data/lib/aka/man/aka-add.1 +1 -1
  11. data/lib/aka/man/aka-add.1.txt +1 -1
  12. data/lib/aka/man/aka-edit.1 +1 -1
  13. data/lib/aka/man/aka-edit.1.txt +1 -1
  14. data/lib/aka/man/aka-generate.1 +1 -1
  15. data/lib/aka/man/aka-generate.1.txt +1 -1
  16. data/lib/aka/man/aka-link.1 +1 -1
  17. data/lib/aka/man/aka-link.1.txt +1 -1
  18. data/lib/aka/man/aka-list.1 +1 -1
  19. data/lib/aka/man/aka-list.1.txt +1 -1
  20. data/lib/aka/man/aka-remove.1 +1 -1
  21. data/lib/aka/man/aka-remove.1.txt +1 -1
  22. data/lib/aka/man/aka-show.1 +1 -1
  23. data/lib/aka/man/aka-show.1.txt +1 -1
  24. data/lib/aka/man/aka-sync.1 +1 -1
  25. data/lib/aka/man/aka-sync.1.txt +1 -1
  26. data/lib/aka/man/aka-upgrade.1 +3 -3
  27. data/lib/aka/man/aka-upgrade.1.txt +3 -3
  28. data/lib/aka/man/aka.7 +4 -4
  29. data/lib/aka/man/aka.7.txt +4 -4
  30. data/lib/aka/shortcut.rb +43 -0
  31. data/lib/aka/{shortcuts.rb → shortcut_manager.rb} +16 -34
  32. data/lib/aka/store.rb +92 -39
  33. data/lib/aka/upgrader.rb +45 -12
  34. data/lib/aka/version.rb +1 -1
  35. data/lib/aka.rb +4 -3
  36. metadata +23 -74
  37. data/.gitignore +0 -11
  38. data/.ruby-version.example +0 -1
  39. data/.travis.yml +0 -4
  40. data/Gemfile +0 -8
  41. data/Guardfile +0 -6
  42. data/Rakefile +0 -98
  43. data/aka.gemspec +0 -28
  44. data/features/aka/add.feature +0 -199
  45. data/features/aka/edit.feature +0 -196
  46. data/features/aka/generate.feature +0 -117
  47. data/features/aka/help.feature +0 -112
  48. data/features/aka/link.feature +0 -339
  49. data/features/aka/list.feature +0 -62
  50. data/features/aka/remove.feature +0 -52
  51. data/features/aka/show.feature +0 -38
  52. data/features/aka/upgrade.feature +0 -137
  53. data/features/step_definitions/aka_steps.rb +0 -3
  54. data/features/support/env.rb +0 -80
  55. data/lib/aka/configuration.rb +0 -94
  56. data/lib/aka/links.rb +0 -33
  57. data/lib/aka/man/.gitkeep +0 -0
  58. data/man/aka-add.1.ronn +0 -32
  59. data/man/aka-edit.1.ronn +0 -67
  60. data/man/aka-generate.1.ronn +0 -51
  61. data/man/aka-link.1.ronn +0 -49
  62. data/man/aka-list.1.ronn +0 -51
  63. data/man/aka-remove.1.ronn +0 -21
  64. data/man/aka-show.1.ronn +0 -27
  65. data/man/aka-sync.1.ronn +0 -31
  66. data/man/aka-upgrade.1.ronn +0 -22
  67. data/man/aka.7.ronn +0 -120
  68. data/test/tc_something.rb +0 -7
@@ -1,94 +0,0 @@
1
- module Aka
2
- class Configuration
3
- FORMAT = '1'
4
-
5
- attr_reader :configuration
6
-
7
- module Shortcut
8
- def self.parse(options)
9
- OpenStruct.new.tap do |row|
10
- row.shortcut = options['shortcut']
11
- row.command = options['command']
12
- row.tag = options['tag'] if options['tag']
13
- row.description = options['description'] if options['description']
14
- row.function = options['function'] if options['function']
15
- end
16
- end
17
-
18
- def self.generate_output(row)
19
- string = if row.function
20
- <<-EOS.gsub(/^ /, '')
21
- function #{row.shortcut} {
22
- #{row.command}
23
- }
24
- EOS
25
- else
26
- %{alias #{row.shortcut}="#{row.command.gsub(%{"}, %{\\"})}"}
27
- end
28
-
29
- string
30
- end
31
- end
32
-
33
- module Link
34
- def self.parse(options)
35
- unless options['tag'] && options['output']
36
- abort("Invalid link.")
37
- end
38
-
39
- OpenStruct.new.tap do |row|
40
- row.tag = options['tag'] if options['tag']
41
- row.output = options['output'] if options['output']
42
- end
43
- end
44
- end
45
-
46
- def initialize
47
- @configuration ||= begin
48
- if File.exist?(aka_yml)
49
- YAML::load_file(aka_yml)
50
- else
51
- {}
52
- end
53
- end
54
- @configuration[:shortcuts] ||= {}
55
- end
56
-
57
- def shortcuts
58
- @shortcuts ||= Shortcuts.new(@configuration[:shortcuts])
59
- end
60
-
61
- def version
62
- @configuration[:version]
63
- end
64
-
65
- def save
66
- current = {
67
- :version => version || FORMAT,
68
- :shortcuts => shortcuts.all
69
- }
70
-
71
- current[:links] = links.all if links.any?
72
-
73
- File.open(aka_yml, 'w+') do |f|
74
- f.write current.to_yaml
75
- end
76
- end
77
-
78
- def links
79
- @links ||= Links.new(@configuration[:links] || {})
80
- end
81
-
82
- def upgrade
83
- if !version
84
- Upgrader::FromV0ToV1.run(aka_yml)
85
- elsif version == '1'
86
- Upgrader::FromV1ToV2.run(aka_yml)
87
- end
88
- end
89
-
90
- def aka_yml
91
- ENV['AKA'] || File.expand_path('~/.aka.yml')
92
- end
93
- end
94
- end
data/lib/aka/links.rb DELETED
@@ -1,33 +0,0 @@
1
- module Aka
2
- class Links
3
- def initialize(links)
4
- @links = links.dup
5
- end
6
-
7
- def add(link)
8
- link = Configuration::Link.parse(link)
9
- @links[count + 1] = link unless @links.find { |_, l| l == link }
10
- end
11
-
12
- def delete(key)
13
- @links.delete(key)
14
- end
15
-
16
- def any?
17
- @links.any?
18
- end
19
-
20
- def all
21
- @links.dup
22
- end
23
-
24
- def each(&blk)
25
- @links.each(&blk)
26
- end
27
-
28
- def count
29
- result, _ = @links.max { |(n, _)| n }
30
- result || 0
31
- end
32
- end
33
- end
data/lib/aka/man/.gitkeep DELETED
File without changes
data/man/aka-add.1.ronn DELETED
@@ -1,32 +0,0 @@
1
- aka-add(1) -- Add keyboard shortcuts
2
- ====================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka add` <shortcut> <command>
7
- [`-d` <description>]
8
- [`-t` <tag1>[,<tag2>...]]
9
- [`-F`]
10
- [`-f`]
11
-
12
- ## DESCRIPTION
13
-
14
- This command adds a keyboard shortcut to `aka(7)`.
15
-
16
- ## OPTIONS
17
-
18
- * `-d <description>`:
19
- Provide a description for the shortcut.
20
-
21
- * `-t` <tag1>[,<tag2>...]:
22
- A comma-separated list of tags for the shortcut.
23
-
24
- * `-F`:
25
- Create the shortcut as a shell function.
26
-
27
- * `-f`:
28
- Ovewrite an existing shortcut if a shortcut exists with the same <shortcut>.
29
-
30
- ## SEE ALSO
31
-
32
- `aka(7)`, `aka-show(1)`
data/man/aka-edit.1.ronn DELETED
@@ -1,67 +0,0 @@
1
- aka-edit(1) -- Edit keyboard shortcuts
2
- ======================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka edit` <shortcut>
7
- [`-i` input]
8
-
9
- ## DESCRIPTION
10
-
11
- This command edits a keyboard shortcut in `aka(7)`.
12
-
13
- The command can be performed interactively or via an input file.
14
-
15
- ## OPTIONS
16
-
17
- * `-i <input>`:
18
- Update the shortcut with an input file. See the "FORMAT" section for more details.
19
-
20
- ## FORMAT
21
-
22
- The format should include the following sections (in order):
23
-
24
- * `Shortcut: <shortcut>`<br>
25
- Where <shortcut> is the string to change the <shortcut> cut.
26
-
27
- * `Description: <description>`<br>
28
- Where <description> is one or more lines of text.
29
-
30
- * `Function (y/n): <y|n>`<br>
31
- Where <y|n> is either `y` or `n`.
32
-
33
- * `Tags: <tags>`<br>
34
- Where <tags> is a comma-separated list of tags for the shortcut.
35
-
36
- * `Command: <command>`<br>
37
- Where <command> is one or more lines of text.
38
-
39
- ## INTERACTIVE MODE
40
-
41
- When the command enters the interactive mode, it shows the <shortcut> in the expected `FORMAT` in an interactive editor.
42
-
43
- ## EXAMPLES
44
-
45
- Edit a shortcut where `input.txt` is:
46
-
47
- Shortcut: lsf
48
- Description:
49
- 1
50
- 2
51
- 3
52
- Function (y/n): y
53
- Tags: zsh, bash
54
- Command:
55
- ls -F
56
-
57
- $ aka edit lsf -i input.txt
58
- Saved shortcut.
59
-
60
- ## ENVIRONMENT
61
-
62
- * `EDITOR`:<br>
63
- The editor **aka** will use in interactive mode. Default: vim
64
-
65
- ## SEE ALSO
66
-
67
- `aka(7)`, `aka-show(1)`
@@ -1,51 +0,0 @@
1
- aka-generate(1) -- Generate commands for loading keyboard shortcuts into your shell
2
- ===================================================================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka generate` [`-t` <tag1>[,<tag2>...]]
7
- [`-o` <output>]
8
-
9
- ## DESCRIPTION
10
-
11
- This command generates commands for loading keyboard shortcuts in `aka(7)` into your shell.
12
-
13
- This command can be performed with or without tag filtering.
14
-
15
- By default, the commands are generated to `STDOUT`.
16
-
17
- ## OPTIONS
18
-
19
- * `-t` <tag1>[,<tag2>...]:
20
- A comma-separated list of tags to filter with. Shortcuts tagged with <tag1>[,<tag2>...] will be included. Shortcuts tagged with other tags are excluded. Shortcuts with no tags are always included.
21
-
22
- * `-o <output>`:
23
- The location to generate the commands to.
24
-
25
- ## EXAMPLES
26
-
27
- Generate for all shortcuts:
28
-
29
- $ aka generate
30
- alias ..="cd .."
31
- alias ls="ls -FG"
32
- function ls {
33
- ls -F --color=auto
34
- }
35
-
36
- Generate for shortcuts matching `--tag os:darwin`:
37
-
38
- $ aka generate -t os:darwin
39
- alias ..="cd .."
40
- alias ls="ls -FG"
41
-
42
- 2 shortcut(s) excluded (#os:linux, #os:windows).
43
-
44
- Generate to file:
45
-
46
- $ aka generate -o ~/.aka.zsh
47
- Generated ~/.aka.zsh.
48
-
49
- ## SEE ALSO
50
-
51
- `aka(7)`, `aka-show(1)`
data/man/aka-link.1.ronn DELETED
@@ -1,49 +0,0 @@
1
- aka-link(1) -- Link keyboard shortcuts
2
- ======================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka link` [`-t` <tag1>[,<tag2>...]]
7
- [`-o` <output>]<br>
8
- `aka link` `delete` *link*
9
-
10
- ## DESCRIPTION
11
-
12
- This command manages keyboard shortcuts links in `aka(7)`.
13
-
14
- After creating a link, you can easily synchronize changes to shortcuts to designated `output` files.
15
-
16
- ## OPTIONS
17
-
18
- * `-t` <tag1>[,<tag2>...]:
19
- A comma-separated list of tags to filter with. Shortcuts tagged with <tag1>[,<tag2>...] will be included. Shortcuts tagged with other tags are excluded. Shortcuts with no tags are always included.
20
-
21
- * `-o <output>`:
22
- The location to link the output to.
23
-
24
- * `delete` *link*:
25
- Delete the link with id *link*.
26
-
27
- ## EXAMPLES
28
-
29
- Add a link:
30
-
31
- $ aka link --tag os:linux --output \~/.aka.zsh
32
- Saved link.
33
-
34
- Remove a link:
35
-
36
- $ aka list
37
- ...
38
- =====
39
- Links
40
- =====
41
-
42
- [1] ~/.aka.zsh: #osx, #git
43
- [2] ~/.aka.zsh: #linux, #git
44
- $ aka link delete 2
45
- Removed link.
46
-
47
- ## SEE ALSO
48
-
49
- `aka(7)`, `aka-sync(1)`
data/man/aka-list.1.ronn DELETED
@@ -1,51 +0,0 @@
1
- aka-list(1) -- List keyboard shortcuts
2
- ======================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka list` [`-t` <tag1>[,<tag2>...]]
7
-
8
- ## DESCRIPTION
9
-
10
- This command lists keyboard shortcuts in `aka(7)`.
11
-
12
- This command can be performed with or without tag filtering.
13
-
14
- ## OPTIONS
15
-
16
- * `-t` <tag1>[,<tag2>...]:
17
- A comma-separated list of tags to filter with. Shortcuts tagged with <tag1>[,<tag2>...] will be included. Shortcuts tagged with other tags are excluded. Shortcuts with no tags are always included.
18
-
19
- ## EXAMPLES
20
-
21
- List all shortcuts:
22
-
23
- $ aka list
24
- #default
25
- ========
26
- .. cd ..
27
-
28
- #os:linux
29
- =========
30
- ls ls; ls; ls
31
-
32
- #os:darwin
33
- ==========
34
- ls ls -FG
35
-
36
- List shortcuts matching `--tag os:darwin`:
37
-
38
- $ aka list -t os:darwin
39
- #default
40
- ========
41
- .. cd ..
42
-
43
- #os:darwin
44
- ==========
45
- ls ls -FG
46
-
47
- 2 shortcut(s) excluded (#os:linux, #os:windows).
48
-
49
- ## SEE ALSO
50
-
51
- `aka(7)`, `aka-show(1)`
@@ -1,21 +0,0 @@
1
- aka-remove(1) -- Remove keyboard shortcuts
2
- ==========================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka remove` <shortcut>
7
-
8
- ## DESCRIPTION
9
-
10
- This command removes a keyboard shortcut from `aka(7)`.
11
-
12
- ## EXAMPLES
13
-
14
- Remove a shortcut:
15
-
16
- $ aka remove ls
17
- Removed shortcut.
18
-
19
- ## SEE ALSO
20
-
21
- `aka(7)`, `aka-show(1)`
data/man/aka-show.1.ronn DELETED
@@ -1,27 +0,0 @@
1
- aka-show(1) -- Show keyboard shortcuts
2
- =====================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka show` <shortcut>
7
-
8
- ## DESCRIPTION
9
-
10
- This command show a keyboard shortcut in `aka(7)`.
11
-
12
- ## EXAMPLES
13
-
14
- $ aka add psf "ps aux | grep $@" --function
15
- Created shortcut.
16
- $ aka show psf
17
- Keyword: psf
18
- Description:
19
-
20
- Function: y
21
- Tags:
22
- Script:
23
- ps aux | grep $@
24
-
25
- ## SEE ALSO
26
-
27
- `aka(7)`, `aka-add(1)`
data/man/aka-sync.1.ronn DELETED
@@ -1,31 +0,0 @@
1
- aka-sync(1) -- Synchronize keyboard shortcuts
2
- =============================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka sync` <link>
7
-
8
- ## DESCRIPTION
9
-
10
- This command manages synchronizes keyboard shortcuts links in `aka(7)`.
11
-
12
- Any links you've created will be generated to the designated `output` with the given `tags`.
13
-
14
- ## OPTIONS
15
-
16
- * `<link>`:
17
- Provide the id of a specific link to synchronize.
18
-
19
- ## EXAMPLES
20
-
21
- Synchronize links:
22
-
23
- $ aka link --tag os:linux --output ~/.aka.zsh
24
- Saved link.
25
- $ aka sync
26
- Generated ~/.aka.zsh.
27
- 4 shortcut(s) excluded (#linux).
28
-
29
- ## SEE ALSO
30
-
31
- `aka(7)`, `aka-link(1)`, `aka-list(1)`
@@ -1,22 +0,0 @@
1
- aka-upgrade(1) -- Upgrade keyboard shortcuts
2
- =========================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka upgrade`
7
-
8
- ## DESCRIPTION
9
-
10
- This command manages upgrades the keyboard shortcuts format in `aka(7)`.
11
-
12
- ## EXAMPLES
13
-
14
- Upgrade links from v0 to v1:
15
-
16
- $ aka upgrade
17
- Upgraded ~/.aka.yml.
18
- Backed up to ~/.aka.yml.backup.
19
-
20
- ## SEE ALSO
21
-
22
- `aka(7)`
data/man/aka.7.ronn DELETED
@@ -1,120 +0,0 @@
1
- aka(7) -- Manage Shell Keyboard Shortcuts
2
- =========================================
3
-
4
- ## SYNOPSIS
5
-
6
- `aka` add <shortcut> <command> \[options\]<br>
7
- `aka` show <shortcut> \[options\]<br>
8
- `aka` edit <shortcut> \[options\]<br>
9
- `aka` remove <shortcut><br>
10
- `aka` list \[options\]<br>
11
- `aka` link \[options\]<br>
12
- `aka` generate \[options\]<br>
13
- `aka` sync<br>
14
- `aka` upgrade
15
-
16
- ## DESCRIPTION
17
-
18
- **aka** is an easy way to manage keyboard shortcuts in UNIX shells.
19
-
20
- You can replace commonly used commands with shorter, sexier keyboard shortcuts and, ultimately, improve your productivity!
21
-
22
- With **aka**, you can add, show, edit, remove, list keyboard shortcuts. On top of that you can tag shortcuts based on environment, tool, context, etc. Then, you can generate an appropriate output file for your environment.
23
-
24
- ## OPTIONS
25
-
26
- * `--help`:<br>
27
- Show help info
28
-
29
- * `--version`:<br>
30
- Show version info
31
-
32
- * `--log-level=<debug|info|warn|error|fatal>`:<br>
33
- Set the logging level (Default: info)
34
-
35
- ## EXAMPLES
36
-
37
- Add a keyboard shortcut and generate the output script:
38
-
39
- $ aka add ls "ls -F --color=auto"
40
- Created shortcut.
41
- $ aka generate
42
- alias ls="ls -F --color=auto"
43
-
44
- Add a keyboard shortcut for a bash/zsh function:
45
-
46
- $ aka add psf "ps aux | grep $@" --function
47
- Created shortcut.
48
- $ aka generate
49
- function psf {
50
- ps aux | grep $@
51
- }
52
-
53
- Generate to a file instead:
54
-
55
- $ aka generate -o ~/.aka.zsh
56
- Generated ~/.aka.zsh.
57
-
58
- Tag a shortcut and generate for OS X:
59
-
60
- $ aka add ls "ls -F --color=auto" --tag os:linux
61
- Created shortcut.
62
- $ aka add ls "ls -FG" --tag os:darwin
63
- Created shortcut.
64
- $ aka generate --tag os:darwin
65
- alias ls="ls -FG"
66
-
67
- Edit a shortcut:
68
-
69
- $ aka edit ls "ls -F --color=auto" --tag os:linux
70
- 1 Shortcut: ls
71
- 2 Description:
72
- 3
73
- 4 Function (y/n): n
74
- 5 Tags: os:linux
75
- 6 Command:
76
- 7 ls -FG
77
- /var/folders/rj/8bjyj6x92l9bxykxc_ljyqsc0000gp/T/shortcut20140222-63006-13csxr0" 7L, 87C
78
- $ :wq
79
-
80
- Remove a shortcut:
81
-
82
- $ aka remove ls
83
- Removes shortcut.
84
-
85
- Add a link:
86
-
87
- $ aka link --tag os:linux --output ~/.aka.zsh
88
- Saved link.
89
-
90
- Remove a link:
91
-
92
- $ aka list
93
- ...
94
- =====
95
- Links
96
- =====
97
-
98
- [1] ~/.aka.zsh: #osx, #git
99
- [2] ~/.aka.zsh: #linux, #git
100
- $ aka link delete 2
101
- Removed link.
102
-
103
- Synchronize links:
104
-
105
- $ aka link --tag os:linux --output ~/.aka.zsh
106
- Saved link.
107
- $ aka sync
108
- Generated ~/.aka.zsh.
109
- 4 shortcut(s) excluded (#linux).
110
-
111
- Upgrade links from v0 to v1:
112
-
113
- $ aka upgrade
114
- Upgraded ~/.aka.yml.
115
- Backed up to ~/.aka.yml.backup."
116
-
117
- ## ENVIRONMENT
118
-
119
- * `AKA`:<br>
120
- The file where **aka** stores everything. Default: ~/.aka.yml
data/test/tc_something.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'test/unit'
2
-
3
- class TestSomething < Test::Unit::TestCase
4
- def test_truth
5
- assert true
6
- end
7
- end