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
7 changed files
with
98 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env fancy | ||
|
||
require: "../lib/fake" | ||
|
||
Fake CLI handle_arguments: ARGV |
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 +1,20 @@ | ||
class Fake | ||
class Fake | ||
|
||
require: "fake/task" | ||
require: "fake/task_builder" | ||
require: "fake/cli" | ||
|
||
class Fake { | ||
def Fake tasks: block { | ||
TasksBuilder new: block . tasks | ||
} | ||
|
||
def Fake read_fakefile: fakefile ("Fakefile") { | ||
try { | ||
File eval: fakefile | ||
} catch Errno::ENOENT => e { | ||
*stderr* println: e | ||
System exit: 1 | ||
} | ||
} | ||
} |
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,19 @@ | ||
class Fake { | ||
class CLI | ||
} | ||
|
||
require: "cli/args" | ||
|
||
class Fake { | ||
class CLI { | ||
def CLI handle_arguments: argv { | ||
parse_argv: argv | ||
Fake read_fakefile: @fakefile | ||
} | ||
|
||
def CLI parse_argv: argv { | ||
@args = Args new: argv | ||
@fakefile = @args parse_option: "-f" | ||
} | ||
} | ||
} |
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,18 @@ | ||
class Fake { | ||
class CLI { | ||
class Args { | ||
Defaults = <[ | ||
"-f" => "Fakefile" | ||
]> | ||
|
||
def initialize: @argv | ||
def parse_option: opt { | ||
if: (@argv index: opt) then: |idx| { | ||
@argv[idx + 1] | ||
} else: { | ||
Defaults[opt] | ||
} | ||
} | ||
} | ||
} | ||
} |
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,10 @@ | ||
class Fake { | ||
class Task { | ||
read_slots: ('name, 'block, 'dependencies) | ||
def initialize: @name block: @block ({}) dependencies: @dependencies ([]); | ||
|
||
def run { | ||
@dependencies | ||
} | ||
} | ||
} |
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,11 @@ | ||
class Fake { | ||
class TaskBuilder { | ||
def initialize: @block { | ||
} | ||
|
||
def tasks { | ||
# TODO | ||
[] | ||
} | ||
} | ||
} |
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,15 @@ | ||
require: "lib/fake/cli/args" | ||
|
||
FancySpec describe: Fake CLI Args with: { | ||
def args: argv { | ||
Fake CLI Args new: argv | ||
} | ||
|
||
it: "returns the default value" for: 'parse_option: when: { | ||
args: [] . parse_option: "-f" . is: $ Fake CLI Args Defaults["-f"] | ||
} | ||
|
||
it: "returns the passed in value" for: 'parse_option: when: { | ||
args: ["-f", "MyCustomFakeFile"] . parse_option: "-f" . is: $ "MyCustomFakeFile" | ||
} | ||
} |