Skip to content

Commit 773bb94

Browse files
committed
Improve comment formatting.
1 parent c48cfd6 commit 773bb94

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

lib/bang.js

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bang.coffee

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ path = require "path"
44
{exec} = require "child_process"
55
os = require "os"
66

7-
# Bang is a program for storing and retrieving text snippets
7+
# **Bang** is a program for storing and retrieving text snippets
88
# on the command line.
99
module.exports = class Bang
1010
# Initializes Bang's data store.
@@ -32,13 +32,12 @@ module.exports = class Bang
3232
@set key, value
3333
else if key
3434
@get key
35+
else if Object.keys(@data).length is 0
36+
@log program.helpInformation()
3537
else
36-
if Object.keys(@data).length is 0
37-
@log program.helpInformation()
38-
else
39-
@list()
38+
@list()
4039

41-
# Data is persisted to disk at ~/.bang.
40+
# Data is persisted to disk at `~/.bang`.
4241
dataPath: process.env.HOME + "/.bang"
4342

4443
# Loads an existing data store or creates a new one.
@@ -50,35 +49,40 @@ module.exports = class Bang
5049
else
5150
{}
5251

53-
# Wraps console.log for testing purposes.
52+
# Wraps `console.log` for testing purposes.
5453
log: (args...) ->
5554
console.log args...
5655

5756
# Writes the data store to disk as JSON.
5857
save: ->
5958
fs.writeFileSync @dataPath, JSON.stringify(@data)
6059

61-
# Retrieve a key's value.
60+
# Retrieves a key's value.
6261
get: (key) ->
6362
value = @data[key]
63+
6464
return unless value
65+
6566
@copy value
6667
@log value
68+
6769
value
6870

69-
# Set the value of a key.
71+
# Sets the value of a key.
7072
set: (key, value) ->
7173
@data[key] = value
7274
@save()
75+
7376
this
7477

75-
# Delete a key.
78+
# Deletes a key.
7679
delete: (key) ->
7780
delete @data[key]
7881
@save()
82+
7983
this
8084

81-
# List all keys and their values.
85+
# Lists all keys and their values.
8286
list: ->
8387
amount = 0
8488

@@ -90,15 +94,15 @@ module.exports = class Bang
9094

9195
this
9296

93-
# Copy a value to the clipboard on Mac OS X and Linux.
97+
# Copies a value to the clipboard on Mac OS X and Linux.
9498
copy: (value) ->
9599
copyCommand = if os.type().match /darwin/i then "pbcopy" else "xclip -selection clipboard"
96100
exec "printf '#{value.replace(/\'/g, "\\'")}' | #{copyCommand}", (error, stdout, stderr) ->
97101
throw error if error
98102

99103
this
100104

101-
# Pad a string by the given amount to line up items nicely.
105+
# Pads a string by the given amount to line up items nicely.
102106
pad: (item, amount) ->
103107
out = ""
104108
i = amount - item.length

0 commit comments

Comments
 (0)