forked from yrashk/expm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
erl_crash.dump | ||
log | ||
/priv/motd | ||
sys.config | ||
sys.config | ||
/expm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
all: ebin | ||
all: expm | ||
|
||
.PHONY: ebin | ||
|
||
ebin: | ||
mix do deps.get, compile | ||
@mix do deps.get, compile | ||
|
||
expm: ebin | ||
@mix escriptize | ||
|
||
start: ebin | ||
@foreman start | ||
@foreman start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
defrecord Expm.CLI, repository: "http://expm.co", username: nil, password: nil do | ||
|
||
def run(["list"], rec) do | ||
run(["search", ""], rec) | ||
end | ||
|
||
def run(["search", kwd], rec) do | ||
repo = repo(rec) | ||
pkgs = Expm.Package.search repo, kwd | ||
lc pkg inlist pkgs do | ||
:io.format("~-20ts ~ts~n",[pkg.name, pkg.description]) | ||
end | ||
end | ||
|
||
def run(["spec",package], rec) do | ||
repo = repo(rec) | ||
case Enum.reverse(List.sort(Expm.Package.versions repo, package)) do | ||
[] -> | ||
IO.puts "No such package" | ||
[version] -> | ||
pkg = Expm.Package.fetch repo, package, version | ||
IO.inspect pkg | ||
end | ||
end | ||
|
||
def run(["publish"], rec) do | ||
run(["publish", "package.exs"], rec) | ||
end | ||
|
||
def run(["publish", file], rec) do | ||
pkg = Expm.Package.read(file) | ||
IO.inspect pkg.publish(repo(rec)) | ||
end | ||
|
||
def run(_, _) do | ||
IO.puts "Invalid command" | ||
end | ||
|
||
defp repo(rec) do | ||
Expm.Repository.HTTP.new(url: repository(rec), | ||
username: username(rec), password: password(rec)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters