confinicky 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile +0 -1
- data/README.md +103 -0
- data/confinicky.gemspec +5 -4
- data/lib/confinicky/commands/clean.rb +3 -3
- data/lib/confinicky/commands/duplicates.rb +5 -3
- data/lib/confinicky/commands/list.rb +3 -3
- data/lib/confinicky/commands/remove.rb +5 -5
- data/lib/confinicky/commands/set.rb +6 -4
- data/lib/confinicky/commands/use.rb +2 -2
- data/lib/confinicky/shell_file.rb +6 -0
- data/lib/confinicky/version.rb +4 -1
- metadata +4 -3
- data/README.rdoc +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 810dc913005260bb414ed9c84763ddcf8e561007
|
4
|
+
data.tar.gz: 4484a749864bcd14c413268cf145fd86c8b816f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4c68cf8114e165ebe6c694e5c2faa4077396dbbc26fa64f3369b034cbb61dcd3c678e540c24b21d3910fa47e1a6165c4190a19bf2b87e9d756c6538da35a3c9
|
7
|
+
data.tar.gz: bde297945fc154d22f1b51661bde4946417f3f25531899f5384f9e8be9de309421976fb17c1e524d2b9ce05348f08131ef3e5c1467073fc30943567841fdb90b
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# Confinicky [![Build Status](https://travis-ci.org/jimjeffers/confinicky.png)](https://travis-ci.org/jimjeffers/confinicky) [![Code Climate](https://codeclimate.com/github/jimjeffers/confinicky.png)](https://codeclimate.com/github/jimjeffers/confinicky) [![Inline docs](http://inch-ci.org/github/jimjeffers/confinicky.png)](http://inch-ci.org/github/jimjeffers/confinicky)
|
2
|
+
|
3
|
+
A simple CLI to manage your environment variables.
|
4
|
+
|
5
|
+
Run `conficky --help` for a current list of useable commands.
|
6
|
+
|
7
|
+
## Setup Confinicky
|
8
|
+
|
9
|
+
First, install the gem:
|
10
|
+
|
11
|
+
```
|
12
|
+
→ gem install confinicky
|
13
|
+
```
|
14
|
+
|
15
|
+
Next, setup confinicky to use your `.bashrc`, `.bash_profile`, or my personal favorite, an external file just for environment variables that you source in your bash_profile. For example I keep mine in a file called `env` and then run `source env` in my `.bash_profile`.
|
16
|
+
|
17
|
+
```
|
18
|
+
→ cfy use /Users/jim/bin/dotfiles/bash/env
|
19
|
+
Set CONFINICKY_FILE_PATH to /Users/jim/bin/dotfiles/bash/env
|
20
|
+
```
|
21
|
+
|
22
|
+
## Listing Environment Variables
|
23
|
+
|
24
|
+
You can easily see all of your environment variables using `cfy list` or `cfy ls`.
|
25
|
+
|
26
|
+
```
|
27
|
+
→ cfy ls
|
28
|
+
+-----------------------+---------------------------------------------------------------------------------------------------------+
|
29
|
+
| CONFINICKY_FILE_PATH | /Users/jim/bin/dotfiles/bash/env |
|
30
|
+
| DOCKER_HOST | tcp://192.168.59.103:2375 |
|
31
|
+
| EDITOR | "subl -w" |
|
32
|
+
| GEM_CERTIFICATE_CHAIN | '~/bin/dotfiles/gem/gem-public_cert.pem' |
|
33
|
+
| GEM_PRIVATE_KEY | '~/bin/dotfiles/gem/gem-private_key.pem' |
|
34
|
+
| INFOPATH | $INFOPATH:/opt/local/share/info |
|
35
|
+
| MANPATH | $MANPATH:/opt/local/share/man:/usr/local/git/man |
|
36
|
+
| NODE_PATH | /usr/local/lib/node:/usr/local/lib/node_modules |
|
37
|
+
| PATH | /Users/jim/.rvm/gems/ruby-2.1.2/bin:/Users/jim/.rvm/gems/ruby-2.1.2@global/bin:/Users/jim/.rvm/rubie... |
|
38
|
+
| PGDATA | /usr/local/var/postgres |
|
39
|
+
| PYTHONPATH | /usr/local/lib/python2.7/site-packages:$PYTHONPATH |
|
40
|
+
| VCPROMPT_FORMAT | "[%n:%b](%m%u)" |
|
41
|
+
+-----------------------+---------------------------------------------------------------------------------------------------------+
|
42
|
+
```
|
43
|
+
|
44
|
+
## Creating / Setting an Environment Variable
|
45
|
+
|
46
|
+
You can easily add or adjust an environment variable using `cfy set` which expects a parameter such as `MY_VAR=value`.
|
47
|
+
|
48
|
+
```
|
49
|
+
→ cfy set DOCKER_HOST=tcp://192.168.59.103:2375
|
50
|
+
Successfully set 'DOCKER_HOST=tcp://192.168.59.103:2375'.
|
51
|
+
Run 'source /Users/jim/bin/dotfiles/bash/env' or open a new terminal/shell window.
|
52
|
+
```
|
53
|
+
|
54
|
+
## Removing an Environment Variable
|
55
|
+
|
56
|
+
You can easily add or adjust an environment variable using `cfy remove` or `cfy rm`.
|
57
|
+
|
58
|
+
```
|
59
|
+
→ cfy remove MY_VAR
|
60
|
+
Successfully removed 'MY_VAR'.
|
61
|
+
Run 'source /Users/jim/bin/dotfiles/bash/env' or open a new terminal/shell window.
|
62
|
+
```
|
63
|
+
|
64
|
+
## Detecting Duplicate Exports
|
65
|
+
|
66
|
+
If your environment files have turned into a junk drawer with PATH getting defined multiple times throughout the file or otherwise, you can get a summary by running `cfy duplicates`.
|
67
|
+
|
68
|
+
```
|
69
|
+
→ cfy duplicates
|
70
|
+
+----------+---+
|
71
|
+
| PATH | 7 |
|
72
|
+
| MANPATH | 3 |
|
73
|
+
| INFOPATH | 3 |
|
74
|
+
+----------+---+
|
75
|
+
Identified 3 variables with multiple 'export' statements in /Users/jim/bin/dotfiles/bash/env
|
76
|
+
Run 'cfy clean' to reduce these statements.
|
77
|
+
```
|
78
|
+
|
79
|
+
## Cleaning Duplicate Exports
|
80
|
+
|
81
|
+
You can run `cfy clean` which replaces multiple export declarations with the actual value of the environment variable.
|
82
|
+
|
83
|
+
```
|
84
|
+
→ cfy clean
|
85
|
+
Backup your existing file before continuuing? (y/n)
|
86
|
+
y
|
87
|
+
Backup saved to: /Users/jim/bin/dotfiles/bash/env1407782855.bak.tmp
|
88
|
+
Your file is clean. 3 duplicate statements have been reduced.
|
89
|
+
```
|
90
|
+
|
91
|
+
## Contributing to confinicky
|
92
|
+
|
93
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
94
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
95
|
+
* Fork the project.
|
96
|
+
* Start a feature/bugfix branch.
|
97
|
+
* Commit and push until you are happy with your contribution.
|
98
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
99
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
100
|
+
|
101
|
+
## Copyright
|
102
|
+
|
103
|
+
Copyright (c) 2014 Jim Jeffers. See LICENSE.txt for further details.
|
data/confinicky.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: confinicky 0.1.
|
5
|
+
# stub: confinicky 0.1.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "confinicky"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -17,14 +17,15 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = ["cfy"]
|
18
18
|
s.extra_rdoc_files = [
|
19
19
|
"LICENSE.txt",
|
20
|
-
"README.
|
20
|
+
"README.md"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
23
|
".document",
|
24
|
+
".travis.yml",
|
24
25
|
"Gemfile",
|
25
26
|
"Gemfile.lock",
|
26
27
|
"LICENSE.txt",
|
27
|
-
"README.
|
28
|
+
"README.md",
|
28
29
|
"Rakefile",
|
29
30
|
"bin/cfy",
|
30
31
|
"confinicky.gemspec",
|
@@ -1,13 +1,13 @@
|
|
1
1
|
command :clean do |c|
|
2
|
-
c.syntax = '
|
2
|
+
c.syntax = 'cfy clean'
|
3
3
|
c.summary = 'Removes all duplicate export statements in the configuration file.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy clean'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
8
|
if Confinicky::ShellFile.has_path?
|
9
9
|
say_error "Please set '#{Confinicky::FILE_PATH_VAR}' to point to your local configuration file."
|
10
|
-
puts "Try running '
|
10
|
+
puts "Try running 'cfy use' for more info."
|
11
11
|
abort
|
12
12
|
end
|
13
13
|
shell_file = Confinicky::ShellFile.new
|
@@ -1,15 +1,17 @@
|
|
1
1
|
command :duplicates do |c|
|
2
|
-
c.syntax = '
|
2
|
+
c.syntax = 'cfy duplicates'
|
3
3
|
c.summary = 'Generates a list of all variables that have multiple export statements.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy duplicates'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
|
+
|
8
9
|
if Confinicky::ShellFile.has_path?
|
9
10
|
say_error "Please set '#{Confinicky::FILE_PATH_VAR}' to point to your local configuration file."
|
10
|
-
puts "Try running '
|
11
|
+
puts "Try running 'cfy use' for more info."
|
11
12
|
abort
|
12
13
|
end
|
14
|
+
|
13
15
|
shell_file = Confinicky::ShellFile.new
|
14
16
|
duplicates = shell_file.find_duplicates.map{|key, value| [key, value]}
|
15
17
|
table = Terminal::Table.new :rows => duplicates
|
@@ -1,14 +1,14 @@
|
|
1
1
|
command :list do |c|
|
2
|
-
c.syntax = '
|
2
|
+
c.syntax = 'cfy list'
|
3
3
|
c.summary = 'Generates a list of all environment variables set in your configuration file.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy list'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
8
|
|
9
9
|
if Confinicky::ShellFile.has_path?
|
10
10
|
say_error "Please set '#{Confinicky::FILE_PATH_VAR}' to point to your local configuration file."
|
11
|
-
puts "Try running '
|
11
|
+
puts "Try running 'cfy use' for more info."
|
12
12
|
abort
|
13
13
|
end
|
14
14
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
command :remove do |c|
|
2
|
-
c.syntax = '
|
2
|
+
c.syntax = 'cfy remove'
|
3
3
|
c.summary = 'Removes an environment variable in your configuration file.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy remove MY_VAR'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
8
|
if Confinicky::ShellFile.has_path?
|
9
9
|
say_error "Please set '#{Confinicky::FILE_PATH_VAR}' to point to your local configuration file."
|
10
|
-
puts "Try running '
|
10
|
+
puts "Try running 'cfy use' for more info."
|
11
11
|
abort
|
12
12
|
end
|
13
13
|
|
@@ -16,13 +16,13 @@ command :remove do |c|
|
|
16
16
|
duplicate_count = shell_file.find_duplicates.length
|
17
17
|
if duplicate_count > 0
|
18
18
|
say_error "Your configuration cannot be managed because it currently has duplicate export statements."
|
19
|
-
puts "You must run '
|
19
|
+
puts "You must run 'cfy clean' before you can manage your configuration."
|
20
20
|
abort
|
21
21
|
end
|
22
22
|
|
23
23
|
if shell_file.remove!(args.first)
|
24
24
|
say_ok "Successfully removed '#{args.first}'."
|
25
|
-
puts "
|
25
|
+
puts "Open a new terminal/shell window for this change to take affect."
|
26
26
|
shell_file.write!
|
27
27
|
else
|
28
28
|
say_error "Could not remove '#{args.first}' please double check to ensure you used the appropriate syntax."
|
@@ -1,13 +1,13 @@
|
|
1
1
|
command :set do |c|
|
2
|
-
c.syntax = '
|
2
|
+
c.syntax = 'cfy set'
|
3
3
|
c.summary = 'Sets an environment variable in your configuration file.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy set MY_VAR="some value"'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
8
|
if Confinicky::ShellFile.has_path?
|
9
9
|
say_error "Please set '#{Confinicky::FILE_PATH_VAR}' to point to your local configuration file."
|
10
|
-
puts "Try running '
|
10
|
+
puts "Try running 'cfy use' for more info."
|
11
11
|
abort
|
12
12
|
end
|
13
13
|
|
@@ -16,10 +16,12 @@ command :set do |c|
|
|
16
16
|
duplicate_count = shell_file.find_duplicates.length
|
17
17
|
if duplicate_count > 0
|
18
18
|
say_error "Your configuration cannot be managed because it currently has duplicate export statements."
|
19
|
-
puts "You must run '
|
19
|
+
puts "You must run 'cfy clean' before you can manage your configuration."
|
20
20
|
abort
|
21
21
|
end
|
22
22
|
|
23
|
+
say_error "You must supply an expression such as: MY_VAR=\"some value\"" and about if args.first.nil?
|
24
|
+
|
23
25
|
if shell_file.set!(args.first)
|
24
26
|
shell_file.write!
|
25
27
|
say_ok "Successfully set '#{args.first}'."
|
@@ -2,14 +2,14 @@ command :use do |c|
|
|
2
2
|
c.syntax = 'confinicky use'
|
3
3
|
c.summary = 'Appends the confinicky file path shell variable to your configuration.'
|
4
4
|
c.description = ''
|
5
|
-
c.example 'description', '
|
5
|
+
c.example 'description', 'cfy use /User/[YOUR_USER_NAME]/.bashrc'
|
6
6
|
|
7
7
|
c.action do |args, options|
|
8
8
|
@file_path = args.first
|
9
9
|
|
10
10
|
if @file_path.nil?
|
11
11
|
say_error "You must specify a path. See example:"
|
12
|
-
puts '
|
12
|
+
puts 'cfy use /User/[YOUR_USER_NAME]/.bashrc'
|
13
13
|
abort
|
14
14
|
end
|
15
15
|
|
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Confinicky
|
4
|
+
##
|
5
|
+
# A model that loads and represents a shell file.
|
4
6
|
class ShellFile
|
5
7
|
|
8
|
+
##
|
9
|
+
# The preserved lines of code from the shell file which confinicky
|
10
|
+
# will write back to the new shell file in the order they were received.
|
6
11
|
attr_reader :lines
|
12
|
+
|
7
13
|
attr_reader :exports
|
8
14
|
##
|
9
15
|
# References the actual file path from the shell configuration.
|
data/lib/confinicky/version.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
module Confinicky
|
2
|
+
##
|
3
|
+
# Defines the version of the gem in an internal manner so that
|
4
|
+
# users of the gem can query it at run time.
|
2
5
|
module Version
|
3
6
|
MAJOR = 0
|
4
7
|
MINOR = 1
|
5
|
-
PATCH =
|
8
|
+
PATCH = 6
|
6
9
|
BUILD = ''
|
7
10
|
|
8
11
|
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confinicky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Jeffers
|
@@ -116,13 +116,14 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files:
|
118
118
|
- LICENSE.txt
|
119
|
-
- README.
|
119
|
+
- README.md
|
120
120
|
files:
|
121
121
|
- ".document"
|
122
|
+
- ".travis.yml"
|
122
123
|
- Gemfile
|
123
124
|
- Gemfile.lock
|
124
125
|
- LICENSE.txt
|
125
|
-
- README.
|
126
|
+
- README.md
|
126
127
|
- Rakefile
|
127
128
|
- bin/cfy
|
128
129
|
- confinicky.gemspec
|
data/README.rdoc
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
= confinicky
|
2
|
-
|
3
|
-
A simple CLI to manage your environment variables.
|
4
|
-
|
5
|
-
Run 'conficky --help' for a current list of useable commands.
|
6
|
-
|
7
|
-
== Contributing to confinicky
|
8
|
-
|
9
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
10
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
11
|
-
* Fork the project.
|
12
|
-
* Start a feature/bugfix branch.
|
13
|
-
* Commit and push until you are happy with your contribution.
|
14
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
15
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
16
|
-
|
17
|
-
== Copyright
|
18
|
-
|
19
|
-
Copyright (c) 2014 Jim Jeffers. See LICENSE.txt for
|
20
|
-
further details.
|
21
|
-
|