Skip to content

Commit 46d6e8a

Browse files
authored
Merge pull request #6 from zipkid/feature/sign
Add sign capability
2 parents 9421cfb + 54eeeff commit 46d6e8a

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

keymaps/atom-gpg.cson

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
'atom-text-editor':
44
'ctrl-E': 'atom-gpg:encrypt-selections'
55
'ctrl-D': 'atom-gpg:decrypt-selections'
6+
'ctrl-S': 'atom-gpg:sign-selections'

lib/gpg.coffee

+21-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ gpgDecrypt = (text, index, callback, stderr_cb, exit_cb) ->
111111
gpgHomeDir = atom.config.get 'atom-gpg.gpgHomeDir'
112112

113113
if gpgHomeDir
114-
args.push '--homedir ' + gpgHomeDir
114+
args.push '--homedir=' + gpgHomeDir
115115

116116
args.push '--decrypt'
117117

@@ -122,5 +122,25 @@ gpgDecrypt = (text, index, callback, stderr_cb, exit_cb) ->
122122
data: text
123123
exit: exit_cb
124124

125+
gpgSign = (text, index, callback, stderr_cb, exit_cb) ->
126+
stdout = (data) ->
127+
callback index, data
128+
129+
args = []
130+
gpgHomeDir = atom.config.get 'atom-gpg.gpgHomeDir'
131+
132+
if gpgHomeDir
133+
args.push '--homedir=' + gpgHomeDir
134+
135+
args.push '--clearsign'
136+
137+
gpgCommand
138+
args: args
139+
stdout: stdout
140+
stderr: stderr_cb
141+
data: text
142+
exit: exit_cb
143+
125144
module.exports.encrypt = gpgEncrypt
126145
module.exports.decrypt = gpgDecrypt
146+
module.exports.sign = gpgSign

lib/main.coffee

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module.exports =
2222
atom.commands.add 'atom-text-editor',
2323
'atom-gpg:encrypt-selections': => @run 'encrypt'
2424
'atom-gpg:decrypt-selections': => @run 'decrypt'
25+
'atom-gpg:sign-selections': => @run 'sign'
2526

2627
bufferSetText: (idx, text) ->
2728
if @buffer[idx]
@@ -112,6 +113,8 @@ module.exports =
112113

113114
if func_name == 'encrypt'
114115
func = gpg.encrypt
116+
else if func_name == 'sign'
117+
func = gpg.sign
115118
else
116119
func = gpg.decrypt
117120

menus/atom-gpg.cson

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
'context-menu':
33
'atom-workspace': [
44
{label: 'GPG Encrypt', command: 'atom-gpg:encrypt-selections'},
5-
{label: 'GPG Decrypt', command: 'atom-gpg:decrypt-selections'}]
5+
{label: 'GPG Decrypt', command: 'atom-gpg:decrypt-selections'},
6+
{label: 'GPG Sign', command: 'atom-gpg:sign-selections'}
7+
]
68

79
'menu': [
810
{
@@ -12,6 +14,7 @@
1214
submenu: [
1315
{ label: 'GPG Encrypt', command: 'atom-gpg:encrypt-selections' }
1416
{ label: 'GPG Decrypt', command: 'atom-gpg:decrypt-selections' }
17+
{ label: 'GPG Sign', command: 'atom-gpg:sign-selections' }
1518
]
1619
]
1720
}

0 commit comments

Comments
 (0)