Skip to content

Commit 978a590

Browse files
committed
2 parents b2a61b6 + 0d97da4 commit 978a590

File tree

13 files changed

+134
-75
lines changed

13 files changed

+134
-75
lines changed

.assets/scripts/completion/bash/hazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
_hazel_complete() {
4+
COMPREPLY=()
5+
local completions
6+
local word="${COMP_WORDS[COMP_CWORD]}"
7+
local line=(${COMP_WORDS[@]})
8+
line=(${COMP_WORDS[@]:1})
9+
10+
if [ $COMP_CWORD -eq 1 ]
11+
then
12+
completions="$(hazel cmplt-bash "${line[@]}")"
13+
else
14+
completions="$(hazel cmplt-bash "${line[@]}" " ")"
15+
fi
16+
17+
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
18+
}
19+
20+
complete -F _hazel_complete hazel

.assets/scripts/completion/completion.bash

Lines changed: 0 additions & 11 deletions
This file was deleted.

.assets/scripts/completion/completion.zsh

Lines changed: 0 additions & 11 deletions
This file was deleted.

.assets/scripts/completion/init.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
if [ -n "$BASH_VERSION" ]; then
44
root="$(dirname "${BASH_SOURCE[0]}")"
5-
source "$root/completion.bash"
5+
source "$root/bash/hazel"
66

77
elif [ -n "$ZSH_VERSION" ]; then
88
root="$(dirname "$0")"
9-
source "$root/completion.zsh"
9+
source "$root/zsh/_hazel"
1010
fi

.assets/scripts/completion/zsh/_hazel

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#compdef hazel
2+
#autoload
3+
4+
_hazel() {
5+
typeset -A opt_args
6+
7+
_arguments -C \
8+
'1:command:->commands' \
9+
'2:argument:->arguments' \
10+
'*:: :->opts' \
11+
&& ret=0
12+
13+
case "$state" in
14+
(commands)
15+
local complete; complete=$(hazel cmplt "${line[1]}")
16+
local commands; commands=(
17+
${(ps:\n:)complete}
18+
)
19+
20+
_describe -t commands 'commands' commands && ret=0
21+
;;
22+
(arguments)
23+
local complete; complete=$(hazel cmplt "${line[@]}")
24+
local argument; argument=(
25+
${(ps:\n:)complete}
26+
)
27+
28+
_describe -t argument 'argument' argument && ret=0
29+
;;
30+
(opts)
31+
local complete; complete=$(hazel cmplt "${line[@]}")
32+
local argument; argument=(
33+
${(ps:\n:)complete}
34+
)
35+
36+
_describe -t argument 'argument' argument && ret=0
37+
esac;
38+
39+
return 1;
40+
}
41+
42+
_hazel "$@"

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ clean:
6161
rm -rf .build/
6262
rm -rf xcov_report
6363
rm -f hazel_debug
64+
65+
compress:
66+
cd ../ && tar czf hazel-1.0.3.tar.gz Hazel
67+
mv ../hazel-1.0.3.tar.gz .
68+
shasum -a 256 hazel-1.0.3.tar.gz

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ let package = Package(
77
name: "Hazel",
88
dependencies: [
99
.package(url: "https://github.com/onevcat/Rainbow", from: "3.0.0"),
10-
// .package(url: "https://github.com/pkrll/SwiftArgs", from: "0.4.0")
11-
.package(url: "https://github.com/pkrll/SwiftArgs", .branch("dev/0.5.4"))
10+
.package(url: "https://github.com/pkrll/SwiftArgs", from: "0.5.0")
1211
],
1312
targets: [
1413
.target(

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
<img src=".assets/hazel.gif" width="40%" align="right">
1212

13+
<img src=".assets/hazel.gif" width="40%" align="right">
14+
1315
## Table of contents
1416

1517
* [Installation](#installation)
@@ -142,7 +144,7 @@ Options:
142144
```
143145
```bash
144146
$ hazel init --help
145-
Usage: hazel init [argument]
147+
Usage: ./hazel_debug init [argument]
146148

147149
Options:
148150
-t, --template Choose project template

Sources/HazelCore/Hazel.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ public struct Hazel {
1919
return
2020
}
2121

22-
var projType: String?
22+
var template: String?
2323
var skipConf: Bool = false
2424

2525
for argument in command.arguments {
2626
switch argument.name {
27-
case "type": projType = (argument as? StringOption)?.value
28-
case "conf": skipConf = (argument as? BoolOption)?.value! ?? false
27+
case "template": template = (argument as? StringOption)?.value
28+
case "skipConf": skipConf = (argument as? BoolOption)?.value! ?? false
2929
default: break
3030
}
3131
}
3232

33-
guard let type = projType else {
34-
self.console.forceQuit(withMessage: "Project type not recognized.")
33+
guard let type = template else {
34+
self.console.forceQuit(withMessage: "No project template given.")
3535
return
3636
}
3737

Sources/HazelCore/Support/Arguments.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public struct Arguments {
1111
public let help: BoolOption
1212
public let quiet: BoolOption
1313
public let version: BoolOption
14-
public let type: StringOption
14+
public let template: StringOption
1515
public let skipConf: BoolOption
1616
public let initialize: CommandOption
1717

@@ -37,24 +37,24 @@ public struct Arguments {
3737
description: "Print version information and exit"
3838
)
3939

40-
self.type = StringOption(
41-
name: "type",
40+
self.template = StringOption(
41+
name: "template",
4242
shortFlag: "t",
43-
longFlag: "type",
44-
description: "Set language for project",
43+
longFlag: "template",
44+
description: "Choose project template",
4545
isRequired: true
4646
)
4747

4848
self.skipConf = BoolOption(
49-
name: "conf",
49+
name: "skipConf",
5050
longFlag: "no-config",
5151
description: "Do not generate .editorconfig"
5252
)
5353

5454
self.initialize = CommandOption(
5555
"init",
5656
withArguments: [
57-
self.type,
57+
self.template,
5858
self.skipConf,
5959
self.help
6060
],

0 commit comments

Comments
 (0)