This commit is contained in:
parent
218d057071
commit
790152ec36
4 changed files with 42 additions and 11 deletions
38
README.md
38
README.md
|
@ -79,31 +79,32 @@ make install
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Packing directory content
|
||||||
|
|
||||||
Run Code-Preloader with the following command-line options:
|
Run Code-Preloader with the following command-line options:
|
||||||
|
|
||||||
```
|
```
|
||||||
CodePreloader v0.1.0
|
Usage: code-preloader pack [options] DIR ...
|
||||||
Usage: code-preloader [options] DIR ...
|
|
||||||
|
|
||||||
Options:
|
Global options:
|
||||||
-c FILE, --config=FILE Load parameters from FILE
|
--version Show version
|
||||||
|
-h, --help Show this help
|
||||||
|
|
||||||
|
Pack options:
|
||||||
-i REGEXP, --ignore=REGEXP Ignore file or directory
|
-i REGEXP, --ignore=REGEXP Ignore file or directory
|
||||||
-o FILE, --output=FILE Write output to FILE
|
-o FILE, --output=FILE Write output to FILE
|
||||||
-H FILE, --header-prompt=FILE Load header prompt from FILE
|
-H FILE, --header-prompt=FILE Load header prompt from FILE
|
||||||
-F FILE, --footer-prompt=FILE Load footer prompt from FILE
|
-F FILE, --footer-prompt=FILE Load footer prompt from FILE
|
||||||
--version Show version
|
-c FILE, --config=FILE Load parameters from FILE
|
||||||
-h, --help Show this help
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
#### Basic Use Case
|
#### Basic Use Case
|
||||||
|
|
||||||
To preload all files in the `src` directory and output to `result.txt`, while
|
To preload all files in the `src` directory and output to `result.txt`, while
|
||||||
ignoring the `git` the `bin` directory, and the result file itself:
|
ignoring the `git` the `bin` directory, and the result file itself:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/code-preloader -o result.txt -i .git -i result.txt -i bin/ src
|
./bin/code-preloader pack -o result.txt -i .git -i result.txt -i bin/ src
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Advanced Use Case
|
#### Advanced Use Case
|
||||||
|
@ -113,7 +114,7 @@ and appending prompts, while ignoring the `git` the `bin` directory, and the
|
||||||
result file itself:
|
result file itself:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./bin/code-preloader \
|
./bin/code-preloader pack \
|
||||||
-i .git -i bin/ -i result.txt -i prompts \
|
-i .git -i bin/ -i result.txt -i prompts \
|
||||||
-H prompts/context.txt -F prompts/request-readme.txt \
|
-H prompts/context.txt -F prompts/request-readme.txt \
|
||||||
src \
|
src \
|
||||||
|
@ -122,7 +123,22 @@ result file itself:
|
||||||
|
|
||||||
__Note__ `ctrlc` is my alias to `xclip -selection clipboard -i`
|
__Note__ `ctrlc` is my alias to `xclip -selection clipboard -i`
|
||||||
|
|
||||||
#### Advanced with configuration file
|
### Creating a config file
|
||||||
|
|
||||||
|
Run Code-Preloader with the following command-line options:
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: code-preloader init [options]
|
||||||
|
|
||||||
|
Global options:
|
||||||
|
--version Show version
|
||||||
|
-h, --help Show this help
|
||||||
|
|
||||||
|
Init options:
|
||||||
|
-c FILE, --config=FILE Load parameters from FILE
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example: Advanced with configuration file
|
||||||
|
|
||||||
You can also do the same by storing all parameters within a configuration file
|
You can also do the same by storing all parameters within a configuration file
|
||||||
(ex: `code_preloader.yml`).
|
(ex: `code_preloader.yml`).
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
version: 2.0
|
version: 2.0
|
||||||
shards:
|
shards:
|
||||||
|
completion:
|
||||||
|
git: https://github.com/f/completion.git
|
||||||
|
version: 0.1.0+git.commit.d8799381b2de14430496199260eca64eb329625f
|
||||||
|
|
||||||
magic:
|
magic:
|
||||||
git: https://github.com/dscottboggs/magic.cr.git
|
git: https://github.com/dscottboggs/magic.cr.git
|
||||||
version: 1.1.0
|
version: 1.1.0
|
||||||
|
|
|
@ -16,6 +16,8 @@ dependencies:
|
||||||
github: alexherbo2/walk.cr
|
github: alexherbo2/walk.cr
|
||||||
version_from_shard:
|
version_from_shard:
|
||||||
github: hugopl/version_from_shard
|
github: hugopl/version_from_shard
|
||||||
|
# completion:
|
||||||
|
# github: f/completion
|
||||||
|
|
||||||
# description: |
|
# description: |
|
||||||
# Short description of chatgpt-preloader
|
# Short description of chatgpt-preloader
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require "option_parser"
|
require "option_parser"
|
||||||
require "yaml"
|
require "yaml"
|
||||||
|
# require "completion"
|
||||||
|
|
||||||
require "./models/root_config"
|
require "./models/root_config"
|
||||||
require "./version"
|
require "./version"
|
||||||
|
@ -72,6 +73,8 @@ module CodePreloader
|
||||||
puts parser
|
puts parser
|
||||||
abort("ERROR: Invalid option #{opt}!")
|
abort("ERROR: Invalid option #{opt}!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# complete_with "code-preloader init", parser
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_pack_options(parser)
|
def parse_pack_options(parser)
|
||||||
|
@ -141,6 +144,8 @@ module CodePreloader
|
||||||
puts parser
|
puts parser
|
||||||
abort("ERROR: Invalid option #{ex}")
|
abort("ERROR: Invalid option #{ex}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# complete_with "code-preloader pack", parser
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_arguments(args : Array(String))
|
def parse_arguments(args : Array(String))
|
||||||
|
@ -179,6 +184,8 @@ module CodePreloader
|
||||||
puts parser
|
puts parser
|
||||||
abort("ERROR: Invalid option #{ex}")
|
abort("ERROR: Invalid option #{ex}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# complete_with "code-preloader", parser
|
||||||
end
|
end
|
||||||
|
|
||||||
@parser.try &.parse(args)
|
@parser.try &.parse(args)
|
||||||
|
@ -193,6 +200,8 @@ module CodePreloader
|
||||||
case @subcommand
|
case @subcommand
|
||||||
when Subcommand::Init then validate_init
|
when Subcommand::Init then validate_init
|
||||||
when Subcommand::Pack then validate_pack
|
when Subcommand::Pack then validate_pack
|
||||||
|
when Subcommand::None, Subcommand::Help, Subcommand::Version
|
||||||
|
# do nothing
|
||||||
else
|
else
|
||||||
abort("Unknown subcommand #{@subcommand}")
|
abort("Unknown subcommand #{@subcommand}")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue