Skip to content

Commit bd02008

Browse files
author
Jake Humphrey
committed
fixing a lot of things
1 parent d39d990 commit bd02008

15 files changed

Lines changed: 122 additions & 78 deletions

File tree

README.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,42 @@
22

33
### Usage
44
```
5-
Codelation CLI V2.0.2
5+
6+
Codelation CLI V2.1.6
67
78
Examples:
8-
codelation --install all Installs all packages
9-
codelation --install all -f Installs all packages without prompting
10-
codelation --install atom Installs atom
9+
codelation install all Installs all packages
10+
codelation install all -f Installs all packages without prompting
11+
codelation install atom Installs atom
1112
1213
Commands:
13-
--help/-h Shows this message
14-
--version/-v Shows the version of this tool
15-
--install/-i cmd Used to install assets. 'cmd' can be any one of the following
16-
17-
all - Everything is installed
18-
atom - Atom is installed with prompts for packages and config
19-
atom-packages - Atom packages are installed
20-
atom-config - Atom config is installed
21-
postgres - Postgres is installed
22-
brew - Brew packages are installed
23-
gems - Gems are installed
24-
ruby - Ruby is installed
25-
config - The config dot files are installed
26-
27-
--force/-f Does not prompt the user (for silent installs)
14+
help/h Shows this message
15+
version/-v Shows the version of this tool
16+
new/n cmd Creates a new project. cmd can be one of the folling
17+
18+
rails [name] - new rails project with the optional name
19+
20+
track/t [name] Tracks the current directory for Atom Project Manager and cmd line quick actions
21+
list/l Lists all tracked projects
22+
untrack/u [name] Untracks the current directory or the given name
23+
open/o name Opens a terminal to the project by tracked alias name
24+
open with atom/oa name Opens a terminal and atom to the project by tracked alias name
25+
clone name Clones a project by name from Codelations Organization or by the url and tracks
26+
install/i cmd Used to install assets. 'cmd' can be any one of the following
27+
28+
all - Everything is installed/Same as empty
29+
atom - Atom is installed with prompts for packages and config
30+
atom-packages - Atom packages are installed
31+
atom-config - Atom config is installed
32+
postgres - Postgres is installed
33+
brew - Brew packages are installed
34+
gems - Gems are installed
35+
ruby - Ruby is installed
36+
config - The config dot files are installed
37+
38+
--force/-f Does not prompt the user (for silent installs)
39+
40+
2841
```
2942

3043
### In this project

apps/cli/lib/cli.ex

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule CLI do
2-
@cli_version "2.1.5"
2+
@cli_version "2.1.6"
33

44
@switches [
55
force: :boolean,
@@ -18,8 +18,9 @@ defmodule CLI do
1818

1919
force = ops[:force] || false
2020

21-
exec(ops, text, force)
2221
IO.puts ""
22+
exec(ops, text, force)
23+
IO.puts IO.ANSI.normal<>""
2324
end
2425

2526
# Aliases
@@ -28,6 +29,7 @@ defmodule CLI do
2829
defp exec(args, ["i"|cmd], force), do: exec(args, ["install"|cmd], force)
2930
defp exec(args, ["n"|cmd], force), do: exec(args, ["new"|cmd], force)
3031
defp exec(args, ["t"|cmd], force), do: exec(args, ["track"|cmd], force)
32+
defp exec(args, ["l"|cmd], force), do: exec(args, ["list"|cmd], force)
3133
defp exec(args, ["u"|cmd], force), do: exec(args, ["untrack"|cmd], force)
3234
defp exec(args, ["o"|cmd], force), do: exec(args, ["open"|cmd], force)
3335
defp exec(args, ["oa"|cmd], force), do: exec(args, ["open", "with", "atom"|cmd], force)
@@ -36,7 +38,7 @@ defmodule CLI do
3638
# Commands
3739
defp exec(_, ["version"|_], _force), do: exec([version: true], nil, nil)
3840
defp exec([version: true], _text, _force) do
39-
IO.puts IO.ANSI.cyan<>"Codelation CLI #{IO.ANSI.light_yellow}V#{@cli_version}"
41+
IO.puts IO.ANSI.cyan<>"Codelation CLI #{IO.ANSI.yellow}V#{@cli_version}"
4042
end
4143

4244
defp exec(_, ["help"|_], _force), do: exec([help: true], nil, nil)
@@ -62,6 +64,10 @@ defmodule CLI do
6264
ProjectManager.Commands.Track.track(Enum.join(cmd, " "))
6365
end
6466

67+
defp exec(_, ["list"], _force) do
68+
ProjectManager.Commands.Track.list()
69+
end
70+
6571
defp exec(_, ["untrack"], _force) do
6672
ProjectManager.Commands.Track.untrack()
6773
end
@@ -94,42 +100,43 @@ defmodule CLI do
94100
end
95101

96102
defp help(banner \\ false) do
97-
IO.puts IO.ANSI.cyan<>"Codelation CLI #{IO.ANSI.light_yellow}V#{@cli_version}"
103+
IO.puts IO.ANSI.cyan<>"Codelation CLI #{IO.ANSI.yellow}V#{@cli_version}"
98104
if banner do
99105
IO.puts ""
100106
IO.puts IO.ANSI.red<>"\t#{banner}"
101107
IO.puts ""
102108
end
103109
IO.puts ""
104110
IO.puts IO.ANSI.blue<>"\tExamples:"
105-
IO.puts IO.ANSI.light_cyan<>"\t\tcodelation install all #{IO.ANSI.cyan}Installs all packages"
106-
IO.puts IO.ANSI.light_cyan<>"\t\tcodelation install all -f #{IO.ANSI.cyan}Installs all packages without prompting"
107-
IO.puts IO.ANSI.light_cyan<>"\t\tcodelation install atom #{IO.ANSI.cyan}Installs atom"
111+
IO.puts IO.ANSI.cyan<>"\t\tcodelation install all #{IO.ANSI.white}Installs all packages"
112+
IO.puts IO.ANSI.cyan<>"\t\tcodelation install all -f #{IO.ANSI.white}Installs all packages without prompting"
113+
IO.puts IO.ANSI.cyan<>"\t\tcodelation install atom #{IO.ANSI.white}Installs atom"
108114
IO.puts ""
109115
IO.puts IO.ANSI.blue<>"\tCommands:"
110-
IO.puts IO.ANSI.light_cyan<>"\t\thelp/h #{IO.ANSI.cyan}Shows this message"
111-
IO.puts IO.ANSI.light_cyan<>"\t\tversion/-v #{IO.ANSI.cyan}Shows the version of this tool"
112-
IO.puts IO.ANSI.light_cyan<>"\t\tnew/n cmd #{IO.ANSI.cyan}Creates a new project. cmd can be one of the folling"
116+
IO.puts IO.ANSI.cyan<>"\t\thelp/h #{IO.ANSI.white}Shows this message"
117+
IO.puts IO.ANSI.cyan<>"\t\tversion/-v #{IO.ANSI.white}Shows the version of this tool"
118+
IO.puts IO.ANSI.cyan<>"\t\tnew/n cmd #{IO.ANSI.white}Creates a new project. cmd can be one of the folling"
113119
IO.puts ""
114-
IO.puts IO.ANSI.light_cyan<>"\t\t rails [name] #{IO.ANSI.cyan}- new rails project with the optional name"
120+
IO.puts IO.ANSI.cyan<>"\t\t rails [name] #{IO.ANSI.white}- new rails project with the optional name"
115121
IO.puts ""
116-
IO.puts IO.ANSI.light_cyan<>"\t\ttrack/t [name] #{IO.ANSI.cyan}Tracks the current directory for Atom Project Manager and cmd line quick actions"
117-
IO.puts IO.ANSI.light_cyan<>"\t\tuntrack/u [name] #{IO.ANSI.cyan}Untracks the current directory or the given name"
118-
IO.puts IO.ANSI.light_cyan<>"\t\topen/o name #{IO.ANSI.cyan}Opens a terminal to the project by tracked alias name"
119-
IO.puts IO.ANSI.light_cyan<>"\t\topen with atom/oa name #{IO.ANSI.cyan}Opens a terminal and atom to the project by tracked alias name"
120-
IO.puts IO.ANSI.light_cyan<>"\t\tclone name #{IO.ANSI.cyan}Clones a project by name from Codelations Organization or by the url and tracks"
121-
IO.puts IO.ANSI.light_cyan<>"\t\tinstall/i cmd #{IO.ANSI.cyan}Used to install assets. 'cmd' can be any one of the following"
122+
IO.puts IO.ANSI.cyan<>"\t\ttrack/t [name] #{IO.ANSI.white}Tracks the current directory for Atom Project Manager and cmd line quick actions"
123+
IO.puts IO.ANSI.cyan<>"\t\tlist/l #{IO.ANSI.white}Lists all tracked projects"
124+
IO.puts IO.ANSI.cyan<>"\t\tuntrack/u [name] #{IO.ANSI.white}Untracks the current directory or the given name"
125+
IO.puts IO.ANSI.cyan<>"\t\topen/o name #{IO.ANSI.white}Opens a terminal to the project by tracked alias name"
126+
IO.puts IO.ANSI.cyan<>"\t\topen with atom/oa name #{IO.ANSI.white}Opens a terminal and atom to the project by tracked alias name"
127+
IO.puts IO.ANSI.cyan<>"\t\tclone name #{IO.ANSI.white}Clones a project by name from Codelations Organization or by the url and tracks"
128+
IO.puts IO.ANSI.cyan<>"\t\tinstall/i cmd #{IO.ANSI.white}Used to install assets. 'cmd' can be any one of the following"
122129
IO.puts ""
123-
IO.puts IO.ANSI.light_cyan<>"\t\t all #{IO.ANSI.cyan}- Everything is installed/Same as empty"
124-
IO.puts IO.ANSI.light_cyan<>"\t\t atom #{IO.ANSI.cyan}- Atom is installed with prompts for packages and config"
125-
IO.puts IO.ANSI.light_cyan<>"\t\t atom-packages #{IO.ANSI.cyan}- Atom packages are installed"
126-
IO.puts IO.ANSI.light_cyan<>"\t\t atom-config #{IO.ANSI.cyan}- Atom config is installed"
127-
IO.puts IO.ANSI.light_cyan<>"\t\t postgres #{IO.ANSI.cyan}- Postgres is installed"
128-
IO.puts IO.ANSI.light_cyan<>"\t\t brew #{IO.ANSI.cyan}- Brew packages are installed"
129-
IO.puts IO.ANSI.light_cyan<>"\t\t gems #{IO.ANSI.cyan}- Gems are installed"
130-
IO.puts IO.ANSI.light_cyan<>"\t\t ruby #{IO.ANSI.cyan}- Ruby is installed"
131-
IO.puts IO.ANSI.light_cyan<>"\t\t config #{IO.ANSI.cyan}- The config dot files are installed"
130+
IO.puts IO.ANSI.cyan<>"\t\t all #{IO.ANSI.white}- Everything is installed/Same as empty"
131+
IO.puts IO.ANSI.cyan<>"\t\t atom #{IO.ANSI.white}- Atom is installed with prompts for packages and config"
132+
IO.puts IO.ANSI.cyan<>"\t\t atom-packages #{IO.ANSI.white}- Atom packages are installed"
133+
IO.puts IO.ANSI.cyan<>"\t\t atom-config #{IO.ANSI.white}- Atom config is installed"
134+
IO.puts IO.ANSI.cyan<>"\t\t postgres #{IO.ANSI.white}- Postgres is installed"
135+
IO.puts IO.ANSI.cyan<>"\t\t brew #{IO.ANSI.white}- Brew packages are installed"
136+
IO.puts IO.ANSI.cyan<>"\t\t gems #{IO.ANSI.white}- Gems are installed"
137+
IO.puts IO.ANSI.cyan<>"\t\t ruby #{IO.ANSI.white}- Ruby is installed"
138+
IO.puts IO.ANSI.cyan<>"\t\t config #{IO.ANSI.white}- The config dot files are installed"
132139
IO.puts ""
133-
IO.puts IO.ANSI.light_cyan<>"\t\t--force/-f #{IO.ANSI.cyan}Does not prompt the user (for silent installs)"
140+
IO.puts IO.ANSI.cyan<>"\t\t--force/-f #{IO.ANSI.white}Does not prompt the user (for silent installs)"
134141
end
135142
end

apps/command_tools/lib/installer/dmg.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule CommandTools.Installer.DMG do
55
def prepare(package_name, url, force) do
66
dmg_image_name = Path.basename(url)
77
dmg_image = Path.join(@download_dir, dmg_image_name)
8-
IO.puts "Downloading #{package_name}..."
8+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"Downloading #{package_name}..."<>IO.ANSI.normal
99
dmg_image = Path.join(@download_dir, dmg_image_name)
1010
CommandTools.download!(url, dmg_image, force)
1111
end
@@ -24,11 +24,11 @@ defmodule CommandTools.Installer.DMG do
2424
{_, stat} = System.cmd("hdiutil",["attach", dmg_image])
2525
IO.puts ""
2626
if stat == 0 do
27-
IO.puts "Installer mounted."
28-
IO.puts "Please install #{package_name} via the installer."
29-
IO.puts "Done."
27+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"Installer mounted."<>IO.ANSI.normal
28+
IO.puts IO.ANSI.magenta<>"Please install #{package_name} via the installer."
29+
IO.puts IO.ANSI.green<>"Done."
3030
else
31-
IO.puts "There was an issue mounting the installer. Make sure it is not already mounted."
31+
IO.puts IO.ANSI.red<>"There was an issue mounting the installer. Make sure it is not already mounted."
3232
end
3333
end
3434
end

apps/command_tools/lib/installer/zip.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule CommandTools.Installer.ZIP do
33
@application_dir "/Applications"
44

55
def prepare(package_name, url, force) do
6-
IO.puts "Downloading #{package_name}..."
6+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"Downloading #{package_name}..."<>IO.ANSI.normal
77
zip_file = Path.join(@download_dir, "#{package_name}.zip")
88
CommandTools.download!(url, zip_file, force)
99
end
@@ -19,12 +19,12 @@ defmodule CommandTools.Installer.ZIP do
1919

2020
if install? do
2121
prepare(package_name, url, force)
22-
IO.puts "Installing #{package_name}..."
22+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"Installing #{package_name}..."<>IO.ANSI.normal
2323
uninstall(Path.join(@application_dir, "#{package_name}.app"))
2424
CommandTools.unzip(zip_file, @download_dir)
2525
System.cmd("mv", [Path.join(@download_dir, "#{package_name}.app"), Path.join(@application_dir, "#{package_name}.app")])
2626
File.chmod!(Path.join([@application_dir, "#{package_name}.app", "Contents", "MacOS", package_name]), 755)
27-
IO.puts "Done."
27+
IO.puts IO.ANSI.green<>"Done."
2828
end
2929
end
3030

apps/command_tools/lib/prompt.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule CommandTools.Prompt do
22
def prompt?(_ask, true), do: true
33
def prompt?(ask, false) do
4-
[answer|_] = String.to_charlist(IO.gets("#{ask} [y/n]: "))
4+
[answer|_] = String.to_charlist(IO.gets(IO.ANSI.magenta<>"#{ask} [y/n]: "<>IO.ANSI.yellow))
55
if <<answer>> == "y" || <<answer>> == "Y" do
66
true
77
else

apps/development_setup/lib/sub_tasks/config/atom.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule DevelopmentSetup.Config.Atom do
22

33
def install(force) do
4+
IO.puts IO.ANSI.yellow<>"Installing Atom Config"
45
atom_file = Path.join([System.user_home, ".atom", "init.coffee"])
56
atom_contents = if File.exists?(atom_file) do
67
{:ok, data} = File.read(atom_file)
@@ -24,6 +25,7 @@ defmodule DevelopmentSetup.Config.Atom do
2425
else
2526
CommandTools.write_file!(key_map_file_path, keymap_file())
2627
end
28+
IO.puts IO.ANSI.green<>"Done."
2729
end
2830

2931
defp keymap_file do

apps/development_setup/lib/sub_tasks/config/dot_files.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule DevelopmentSetup.Config.DotFiles do
22
def install(force) do
3+
IO.puts IO.ANSI.yellow<>"Installing Additional Config Files"
34
home_directory = System.user_home
45
bash_directory = Path.join([home_directory, ".codelation", "bash"])
56

@@ -19,6 +20,7 @@ defmodule DevelopmentSetup.Config.DotFiles do
1920
bash_rc = bash_rc <> "\nsource ~/.codelation/bash/codelation.bash"
2021
File.write!(Path.join(home_directory, ".bash_profile"), bash_rc)
2122
end
23+
IO.puts IO.ANSI.green<>"Done."
2224
end
2325

2426
def write_file(file, content, force) do

apps/development_setup/lib/sub_tasks/other/ruby.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ defmodule DevelopmentSetup.Other.Ruby do
1010
def install(_force) do
1111
{version, _} = System.cmd("ruby", ["-v"])
1212
if !String.contains?(version, ruby_version) do
13+
IO.puts IO.ANSI.yellow<>"Installing Ruby Version "<>IO.ANSI.blue<>ruby_version
1314
System.cmd("ruby-install", ["ruby", ruby_version])
15+
IO.puts IO.ANSI.green<>"Done."
1416
end
1517
end
1618

apps/development_setup/lib/sub_tasks/packages/atom.ex

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,20 @@ defmodule DevelopmentSetup.Packages.Atom do
3535
)
3636

3737
def install(_force) do
38+
IO.puts IO.ANSI.yellow<>"Installing Atom packages"
3839
if File.exists?("/Applications/Atom.app/Contents/Resources/app/apm/bin/apm") do
39-
IO.puts "Installing Atom packages..."
40-
4140
@packages
4241
|> Enum.map(&install_package(&1))
4342

44-
IO.puts "Done."
43+
IO.puts IO.ANSI.green<>"Done."
4544
else
46-
IO.puts "Couldn't find the Atom package manager"
45+
IO.puts IO.ANSI.red<>"Couldn't find the Atom package manager"
4746
end
4847
end
4948

5049
defp install_package(package) do
5150
if !File.exists?(Path.join(System.user_home, ".atom/packages/#{package}")) do
52-
IO.puts " Atom - Installing #{package}"
51+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tAtom - Installing #{package}"<>IO.ANSI.normal
5352
System.cmd("/Applications/Atom.app/Contents/Resources/app/apm/bin/apm", ["i", package])
5453
end
5554
end

apps/development_setup/lib/sub_tasks/packages/brew.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule DevelopmentSetup.Packages.Brew do
1919
)
2020

2121
def install(force) do
22-
IO.puts "Installing Brew packages..."
22+
IO.puts IO.ANSI.yellow<>"Installing Brew packages"
2323
aipt = Task.async(fn -> all_installed_packages() end)
2424
aobpt = Task.async(fn -> all_outdated_brew_packages() end)
2525
all = Task.await(aipt, 100000)
@@ -28,28 +28,28 @@ defmodule DevelopmentSetup.Packages.Brew do
2828
@formulas
2929
|> Enum.map(&install_package(&1, all, outdated, force))
3030

31-
IO.puts "Done."
31+
IO.puts IO.ANSI.green<>"Done."
3232
end
3333

3434
defp install_package(pack, all, outdated, force) do
3535
if MapSet.member?(all, pack) do # Already installed
3636
if MapSet.member?(outdated, pack) do # Outdated
3737
if CommandTools.prompt?("#{pack} is already installed but outdated. would you like to update it?", force) do
38-
IO.puts "Updating #{pack}..."
38+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tUpdating #{pack}..."<>IO.ANSI.normal
3939
System.cmd("brew", ["upgrade", pack])
4040
end
4141
else
4242
if CommandTools.prompt?("#{pack} is already installed. Would you like reinstall it?", force) do
43-
IO.puts "Unlinking #{pack}..."
43+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tUnlinking #{pack}..."<>IO.ANSI.normal
4444
System.cmd("brew", ["unlink", pack])
45-
IO.puts "Installing #{pack}..."
45+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tInstalling #{pack}..."<>IO.ANSI.normal
4646
System.cmd("brew", ["install", pack])
47-
IO.puts "Linking #{pack}..."
47+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tLinking #{pack}..."<>IO.ANSI.normal
4848
System.cmd("brew", ["link", pack])
4949
end
5050
end
5151
else
52-
IO.puts "Installing #{pack}..."
52+
IO.puts IO.ANSI.white<>IO.ANSI.faint<>"\tInstalling #{pack}..."<>IO.ANSI.normal
5353
System.cmd("brew", ["install", pack])
5454
end
5555
end

0 commit comments

Comments
 (0)