1
2
3
4
5
6
7 package com.varmateo.yawg.cli;
8
9 import java.io.OutputStream;
10
11 import io.vavr.collection.List;
12 import io.vavr.collection.Seq;
13
14
15
16
17
18 public final class BakerCliRunOptions {
19
20
21 private static final String DEFAULT_ARGV0 = "yawg";
22
23
24 public final String argv0;
25 public final String[] args;
26 public final OutputStream output;
27
28
29
30
31
32 private BakerCliRunOptions(final Builder builder) {
33
34 argv0 = builder._argv0;
35 args = builder._args.toJavaArray(String.class);
36 output = builder._output;
37 }
38
39
40
41
42
43
44
45
46 public static Builder builder() {
47
48 return new Builder();
49 }
50
51
52
53
54
55 public static final class Builder {
56
57
58 private String _argv0;
59 private Seq<String> _args;
60 private OutputStream _output;
61
62
63
64
65
66 private Builder() {
67
68 _argv0 = DEFAULT_ARGV0;
69 _args = List.of();
70 _output = System.out;
71 }
72
73
74
75
76
77
78
79 public Builder argv0(final String argv0) {
80
81 _argv0 = argv0;
82
83 return this;
84 }
85
86
87
88
89
90
91 public Builder addArgs(final String... args) {
92
93 _args = _args.appendAll(List.of(args));
94
95 return this;
96 }
97
98
99
100
101
102 public Builder output(final OutputStream output) {
103
104 _output = output;
105
106 return this;
107 }
108
109
110
111
112
113 public BakerCliRunOptions build() {
114
115 return new BakerCliRunOptions(this);
116 }
117
118
119 }
120
121
122 }