-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* np4: Add reopen support to p4 runner * np4: Add reopen command
- Loading branch information
1 parent
12a76fe
commit f08f068
Showing
4 changed files
with
53 additions
and
3 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
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,37 @@ | ||
import "std.ns" | ||
|
||
import "../perforce/runner.ns" | ||
|
||
import "../utils/shared-writers.ns" | ||
import "../utils/style.ns" | ||
import "../utils/tracer.ns" | ||
|
||
// -- Writers. | ||
|
||
fun reopenOutputWriter() -> Writer{List{P4ReopenResult}} | ||
( | ||
listWriter(depotPathWriter() & newlineWriter()) | ||
).map(lambda (List{P4ReopenResult} r) r.map(lambda (P4ReopenResult result) result.depotFile)) | ||
|
||
|
||
// -- Driver. | ||
|
||
struct ReopenSettings = | ||
bool noColor, | ||
bool trace, | ||
CliPositional{P4Change} change, | ||
CliPositional{P4Path} path | ||
|
||
fun cliDefaults(Type{ReopenSettings} t) | ||
CliDefault("path", "//...") :: List{CliDefault}() | ||
|
||
act reopenCmd(ReopenSettings s) -> Option{Error} | ||
c = consoleOpen().failOnError(); | ||
styleCtx = StyleCtx(!s.noColor && c.allowColor()); | ||
tracer = s.trace ? p4ConsoleTracer(c, styleCtx) : P4Tracer(); | ||
writer = reopenOutputWriter(); | ||
resultsOrErr = loadConfig().map(impure lambda (Config cfg) | ||
p4Reopen(P4RunContext(cfg, tracer), s.change.val, s.path.val) | ||
); | ||
if resultsOrErr as Error err -> err | ||
if resultsOrErr as List{P4ReopenResult} results -> c.writeOut(writer, results) |
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,7 @@ | ||
import "std.ns" | ||
|
||
import "file.ns" | ||
|
||
// -- Types. | ||
|
||
struct P4ReopenResult = P4DepotPath depotFile |
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