Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
erdnaxeli committed Apr 4, 2021
1 parent 7068f9d commit 606ceac
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 10 deletions.
70 changes: 61 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# clip
# Clip

TODO: Write a description here
Clip (CLI Parser) allows you to deserialize CLI parameters into an object, and
generates the help for you.

The goal of Clip is to let you in control.
It does not execute your code.
It does not print anything.
It can read from ARGV but also from any array of strings.
You choose what you want to do.

## Installation

Expand All @@ -9,31 +16,76 @@ TODO: Write a description here
```yaml
dependencies:
clip:
github: your-github-user/clip
github: erdnaxeli/clip
```
2. Run `shards install`

## Usage

In a file command.cr:
```crystal
require "clip"
require "./src/clip"
@[Clip::Doc("An example commmand.")]
struct Command
include Clip::Mapper
@[Clip::Doc("Enable some effect.")]
getter effect = false
@[Clip::Doc("The file to work on.")]
getter file : String
end
begin
command = Command.parse
rescue ex : Clip::ParsingError
puts ex
exit
end
if command.is_a?(Command::Help)
puts Command.help
else
if command.effect
puts "Doing something with an effect on #{command.file}."
else
puts "Doing something on #{command.file}."
end
end
```

TODO: Write usage instructions here
Then:
```Shell
$ crystal build command.cr
$ ./command
Error:
argument is required: FILE
$ ./command --help
Usage: ./command [OPTIONS] FILE
## Development
An example commmand.
TODO: Write development instructions here
Arguments:
FILE The file to work on. [required]
Options:
--effect / --no-effect Enable some effect. [default: false]
$ ./command myfile
Doing something on myfile.
$ ./command --effect myfile
Doing something with an effect on myfile.
```

## Contributing

1. Fork it (<https://github.com/your-github-user/clip/fork>)
1. Fork it (<https://github.com/erdnaxeli/clip/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [Alexandre Morignot](https://github.com/your-github-user) - creator and maintainer
- [Alexandre Morignot](https://github.com/erdnaxeli) - creator and maintainer
2 changes: 1 addition & 1 deletion src/clip/parse.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Clip::Parse
def parse(command : Array(String)) : self | Clip::Mapper::Help
def parse(command : Array(String) = ARGV) : self | Clip::Mapper::Help
if command.includes?("--help")
Clip::Mapper::Help::INSTANCE
else
Expand Down

0 comments on commit 606ceac

Please # to comment.