11#!/usr/bin/env -S deno run --allow-read --allow-run=bash,git,cargo --allow-env --allow-sys
22
33import * as zx from 'npm:zx'
4- import { z , ZodSchema } from " https://deno.land/x/[email protected] /mod.ts" ; 4+ import { z , ZodSchema } from ' https://deno.land/x/[email protected] /mod.ts' 55import { assertEquals } from 'https://jsr.io/@std/assert/1.0.0/equals.ts'
66
77const CargoToml = z . object ( {
@@ -14,9 +14,9 @@ const CargoToml = z.object({
1414 title : z . string ( ) . min ( 1 ) ,
1515 tagline : z . string ( ) ,
1616 summary : z . string ( ) ,
17- } )
18- } )
19- } )
17+ } ) ,
18+ } ) ,
19+ } ) ,
2020} )
2121
2222type CargoToml = z . infer < typeof CargoToml > ;
@@ -28,17 +28,17 @@ const Repo = z.object({
2828type Repo = z . infer < typeof Repo > ;
2929
3030const $ = zx . $ ( {
31- cwd : import . meta. dirname
31+ cwd : import . meta. dirname ,
3232} )
3333const parse = < T > ( schema : ZodSchema < T > , input : { toString : ( ) => string } ) => schema . parse ( JSON . parse ( input . toString ( ) ) )
3434const renderMarkdownList = ( items : string [ ] ) => items . map ( bin => `* ${ bin } ` ) . join ( '\n' )
3535
3636const theCargoToml : CargoToml = parse ( CargoToml , await $ `yj -t < Cargo.toml` )
37- const { package : { name, description, metadata : { details : { title} } } } = theCargoToml
37+ const { package : { name, description, metadata : { details : { title } } } } = theCargoToml
3838const bin = name
3939const help = await $ `cargo run --quiet --bin ${ bin } -- --help`
4040const repo : Repo = parse ( Repo , await $ `gh repo view --json url` )
41- const extraBins = ( await $ `find src/bin/*.rs -type f -exec basename {} .rs \\;` ) . valueOf ( ) . split ( "\n" )
41+ const extraBins = ( await $ `find src/bin/*.rs -type f -exec basename {} .rs \\;` ) . valueOf ( ) . split ( '\n' )
4242
4343assertEquals ( repo . url , theCargoToml . package . repository )
4444
@@ -73,17 +73,18 @@ ${bin} --name my-new-project --copy-configs-from ~/workspace/my-existing-project
7373${ bin } --name my-new-project --dir ~/workspace/my-new-project
7474
7575# Create a public repo
76- ${ bin } --name my-new-project --public
76+ ${ bin } --name my-new-project --repo-create-cmd "gh repo create -- public {{name}}"
7777
7878# Create a lib instead of bin
79- ${ bin } --name my-new-project --cargo -init-args ' --lib'
79+ ${ bin } --name my-new-project --project -init-cmd "cargo init --lib"
8080\`\`\`
8181
8282## Features
8383
84- * Uses existing \`gh\`, \`git\`, \`cargo\` commands
85- * Forwards the flags to commands
86- * Can be used as a library
84+ * [x] Uses existing \`gh\`, \`git\`, \`cargo\` commands
85+ * [x] Supports overrides for all commands
86+ * [x] Supports substitutions (see help below)
87+ * [x] Can be used as a library
8788
8889## Installation
8990
0 commit comments