@@ -46,14 +46,28 @@ pub struct InitArgs {
4646 #[ arg( long, conflicts_with = "template" ) ]
4747 pub use_parent_git : bool ,
4848
49+ /// Do not create example contracts (Counter.sol, Counter.t.sol, Counter.s.sol).
50+ #[ arg( long, conflicts_with = "template" ) ]
51+ pub empty : bool ,
52+
4953 #[ command( flatten) ]
5054 pub install : DependencyInstallOpts ,
5155}
5256
5357impl InitArgs {
5458 pub fn run ( self ) -> Result < ( ) > {
55- let Self { root, template, branch, install, offline, force, vscode, use_parent_git, vyper } =
56- self ;
59+ let Self {
60+ root,
61+ template,
62+ branch,
63+ install,
64+ offline,
65+ force,
66+ vscode,
67+ use_parent_git,
68+ vyper,
69+ empty,
70+ } = self ;
5771 let DependencyInstallOpts { shallow, no_git, commit } = install;
5872
5973 // create the root dir if it does not exist
@@ -128,41 +142,56 @@ impl InitArgs {
128142 let script = root. join ( "script" ) ;
129143 fs:: create_dir_all ( & script) ?;
130144
131- if vyper {
132- // write the contract file
133- let contract_path = src. join ( "Counter.vy" ) ;
134- fs:: write ( contract_path, include_str ! ( "../../assets/vyper/CounterTemplate.vy" ) ) ?;
135- let interface_path = src. join ( "ICounter.sol" ) ;
136- fs:: write ( interface_path, include_str ! ( "../../assets/vyper/ICounterTemplate.sol" ) ) ?;
137-
138- // write the tests
139- let contract_path = test. join ( "Counter.t.sol" ) ;
140- fs:: write ( contract_path, include_str ! ( "../../assets/vyper/CounterTemplate.t.sol" ) ) ?;
141-
142- // write the script
143- let contract_path = script. join ( "Counter.s.sol" ) ;
144- fs:: write ( contract_path, include_str ! ( "../../assets/vyper/CounterTemplate.s.sol" ) ) ?;
145- } else {
146- // write the contract file
147- let contract_path = src. join ( "Counter.sol" ) ;
148- fs:: write (
149- contract_path,
150- include_str ! ( "../../assets/solidity/CounterTemplate.sol" ) ,
151- ) ?;
152-
153- // write the tests
154- let contract_path = test. join ( "Counter.t.sol" ) ;
155- fs:: write (
156- contract_path,
157- include_str ! ( "../../assets/solidity/CounterTemplate.t.sol" ) ,
158- ) ?;
159-
160- // write the script
161- let contract_path = script. join ( "Counter.s.sol" ) ;
162- fs:: write (
163- contract_path,
164- include_str ! ( "../../assets/solidity/CounterTemplate.s.sol" ) ,
165- ) ?;
145+ // Only create example contracts if not disabled
146+ if !empty {
147+ if vyper {
148+ // write the contract file
149+ let contract_path = src. join ( "Counter.vy" ) ;
150+ fs:: write (
151+ contract_path,
152+ include_str ! ( "../../assets/vyper/CounterTemplate.vy" ) ,
153+ ) ?;
154+ let interface_path = src. join ( "ICounter.sol" ) ;
155+ fs:: write (
156+ interface_path,
157+ include_str ! ( "../../assets/vyper/ICounterTemplate.sol" ) ,
158+ ) ?;
159+
160+ // write the tests
161+ let contract_path = test. join ( "Counter.t.sol" ) ;
162+ fs:: write (
163+ contract_path,
164+ include_str ! ( "../../assets/vyper/CounterTemplate.t.sol" ) ,
165+ ) ?;
166+
167+ // write the script
168+ let contract_path = script. join ( "Counter.s.sol" ) ;
169+ fs:: write (
170+ contract_path,
171+ include_str ! ( "../../assets/vyper/CounterTemplate.s.sol" ) ,
172+ ) ?;
173+ } else {
174+ // write the contract file
175+ let contract_path = src. join ( "Counter.sol" ) ;
176+ fs:: write (
177+ contract_path,
178+ include_str ! ( "../../assets/solidity/CounterTemplate.sol" ) ,
179+ ) ?;
180+
181+ // write the tests
182+ let contract_path = test. join ( "Counter.t.sol" ) ;
183+ fs:: write (
184+ contract_path,
185+ include_str ! ( "../../assets/solidity/CounterTemplate.t.sol" ) ,
186+ ) ?;
187+
188+ // write the script
189+ let contract_path = script. join ( "Counter.s.sol" ) ;
190+ fs:: write (
191+ contract_path,
192+ include_str ! ( "../../assets/solidity/CounterTemplate.s.sol" ) ,
193+ ) ?;
194+ }
166195 }
167196
168197 // Write the default README file
0 commit comments