Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --path flag #53

Merged
merged 8 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename path to directory
  • Loading branch information
ordepdev committed Nov 19, 2019
commit 3c9211c70a933e37667d480cd98f50a764c95ade
2 changes: 1 addition & 1 deletion corral/cmd/cmd_add.pony
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ primitive CmdAdd
"\nadd: adding: " + dd.locator.string() + " "
+ dd.version.string() + " " + ld.revision.string())

match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
try
bundle.add_dep(dd, ld)
Expand Down
2 changes: 1 addition & 1 deletion corral/cmd/cmd_clean.pony
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ primitive CmdClean
fun apply(ctx: Context, cmd: Command) =>
//ctx.log.info("clean: " + cmd.string())

match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
try
let repos_dir = ctx.repo_cache
Expand Down
2 changes: 1 addition & 1 deletion corral/cmd/cmd_fetch.pony
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CmdFetch
new create(ctx': Context, cmd: Command) =>
ctx = ctx'
ctx.env.out.print("\nfetch:")
match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
fetch_bundle_deps(bundle, bundle)
| let err: Error =>
Expand Down
5 changes: 4 additions & 1 deletion corral/cmd/cmd_info.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use "../util"

primitive CmdInfo
fun apply(ctx: Context, cmd: Command) =>
match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
//ctx.log.info("info: " + cmd.string())
ctx.env.out.print("\ninfo: from dir " + ctx.directory)

match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
ctx.env.out.print(
" information from " + Files.bundle_filename()
Expand Down
5 changes: 3 additions & 2 deletions corral/cmd/cmd_init.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ use "../util"

primitive CmdInit
fun apply(ctx: Context, cmd: Command) =>
ctx.env.out.print("\ninit: from dir " + ctx.path)
//ctx.log.info("init: " + cmd.string())
ctx.env.out.print("\ninit: from dir " + ctx.directory)

// TODO: try to read first to convert/update existing file(s)
match BundleFile.create_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.create_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
try
bundle.save()?
Expand Down
5 changes: 3 additions & 2 deletions corral/cmd/cmd_list.pony
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use "../util"

primitive CmdList
fun apply(ctx: Context, cmd: Command) =>
ctx.env.out.print("\nlist: from dir " + ctx.path)
//ctx.log.info("list: " + cmd.string())
ctx.env.out.print("\nlist: from dir " + ctx.directory)

match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>

ctx.env.out.print(
Expand Down
3 changes: 2 additions & 1 deletion corral/cmd/cmd_remove.pony
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use "../util"

primitive CmdRemove
fun apply(ctx: Context, cmd: Command) =>
//ctx.log.info("remove: " + cmd.string())
ctx.env.out.print("\nremove: removing: TODO")

match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
try
// TODO: lookup dep
Expand Down
3 changes: 2 additions & 1 deletion corral/cmd/cmd_run.pony
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class CmdRun

new create(ctx': Context, cmd: Command) =>
ctx = ctx'
//ctx.log.info("run: " + cmd.string())

let argss = cmd.arg("args").string_seq()
let args = recover val Array[String].create() .> append(argss) end
Expand All @@ -16,7 +17,7 @@ class CmdRun

// Build a : separated path from bundle roots.
let ponypath = recover val
match BundleFile.load_bundle(ctx.env, ctx.path, ctx.log)
match BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log)
| let bundle: Bundle =>
var ponypath' = recover trn String end
let iter = bundle.bundle_roots().values()
Expand Down
2 changes: 1 addition & 1 deletion corral/cmd/cmd_update.pony
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ primitive CmdUpdate

ctx.env.out.print("\nupdate:")

match recover BundleFile.load_bundle(ctx.env, ctx.path, ctx.log) end
match recover BundleFile.load_bundle(ctx.env, ctx.directory, ctx.log) end
| let bundle: Bundle iso =>
_Updater(ctx).update_bundle_deps(consume bundle)
| let err: Error =>
Expand Down
6 changes: 3 additions & 3 deletions corral/cmd/context.pony
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ class val Context
Contains options and environment for all commands.
"""
let env: Env
let path: String
let log: Log
let quiet: Bool
let nothing: Bool
let directory: String
cquinn marked this conversation as resolved.
Show resolved Hide resolved
let repo_cache: FilePath
let corral_base: FilePath

new val create(env': Env,
path': String,
directory': String,
log': Log,
quiet': Bool, nothing': Bool, repo_cache': String, corral_base': String) ?
=>
env = env'
path = path'
log = log'
quiet = quiet'
nothing = nothing'
directory = directory'
repo_cache = FilePath(env.root as AmbientAuth, repo_cache')?
corral_base = FilePath(env.root as AmbientAuth, corral_base')?
37 changes: 19 additions & 18 deletions corral/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ actor Main
+ " skeletal information.",
[
OptionSpec.string(
"path",
"directory",
"The path where corral.json and dep-lock.json will be created."
cquinn marked this conversation as resolved.
Show resolved Hide resolved
where short' = 'p',
default' = "")
Expand All @@ -55,8 +55,8 @@ actor Main
+ " corral.json.",
[
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
])?
Expand All @@ -75,8 +75,8 @@ actor Main
where short' = 'r',
default' = "")
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
],
Expand All @@ -88,8 +88,8 @@ actor Main
"Removes one or more deps from the corral.",
[
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
])?
Expand All @@ -98,8 +98,8 @@ actor Main
"Lists the deps and packages, including corral details.",
[
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
]
Expand All @@ -120,8 +120,8 @@ actor Main
where short' = 'r',
default' = false)
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
])?
Expand All @@ -131,8 +131,8 @@ actor Main
+ " best revisions.",
[
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
])?
Expand All @@ -141,8 +141,8 @@ actor Main
"Fetches one or more or all of the deps into the corral.",
[
OptionSpec.string(
"path",
"The path where both corral.json and dep-lock.json lives."
"directory",
"The path where both corral.json and dep-lock.json live."
where short' = 'p',
default' = "")
])?
Expand Down Expand Up @@ -179,17 +179,18 @@ actor Main
let quiet = cmd.option("quiet").bool()
let verbose = cmd.option("verbose").bool()
let nothing = cmd.option("nothing").bool()
let path = match cmd.option("path").string()
let directory = match cmd.option("directory").string()
| "" => Path.cwd()
| let path': String => Path.clean(path')
| let dir': String => Path.clean(dir')
end
let repo_cache = "./_repos" // TODO: move default to user home and add flag
let corral_base = "./_corral"
//log.fine("Cmd: " + cmd.string())

try
let context =
recover Context(env, path, log, quiet, nothing, repo_cache, corral_base)? end
recover Context(env, directory, log,
quiet, nothing,repo_cache, corral_base)? end

match cmd.fullname()
| "corral/version" => env.out.print("corral " + Info.version())
Expand Down