Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisGorbachev committed Jul 20, 2024
1 parent cb50791 commit cceecb2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ create-rust-github-repo --name my-new-project --copy-configs-from ~/workspace/my
create-rust-github-repo --name my-new-project --dir ~/workspace/my-new-project

# Create a public repo
create-rust-github-repo --name my-new-project --public
create-rust-github-repo --name my-new-project --repo-create-cmd "gh repo create --public {{name}}"

# Create a lib instead of bin
create-rust-github-repo --name my-new-project --cargo-init-args '--lib'
create-rust-github-repo --name my-new-project --project-init-cmd "cargo init --lib"
```

## Features

* Uses existing `gh`, `git`, `cargo` commands
* Forwards the flags to commands
* Can be used as a library
* [x] Uses existing `gh`, `git`, `cargo` commands
* [x] Supports overrides for all commands
* [x] Supports substitutions (see help below)
* [x] Can be used as a library

## Installation

Expand Down
25 changes: 13 additions & 12 deletions README.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env -S deno run --allow-read --allow-run=bash,git,cargo --allow-env --allow-sys

import * as zx from 'npm:zx'
import { z, ZodSchema } from "https://deno.land/x/[email protected]/mod.ts";
import { z, ZodSchema } from 'https://deno.land/x/[email protected]/mod.ts'
import { assertEquals } from 'https://jsr.io/@std/assert/1.0.0/equals.ts'

const CargoToml = z.object({
Expand All @@ -14,9 +14,9 @@ const CargoToml = z.object({
title: z.string().min(1),
tagline: z.string(),
summary: z.string(),
})
})
})
}),
}),
}),
})

type CargoToml = z.infer<typeof CargoToml>;
Expand All @@ -28,17 +28,17 @@ const Repo = z.object({
type Repo = z.infer<typeof Repo>;

const $ = zx.$({
cwd: import.meta.dirname
cwd: import.meta.dirname,
})
const parse = <T>(schema: ZodSchema<T>, input: { toString: () => string }) => schema.parse(JSON.parse(input.toString()))
const renderMarkdownList = (items: string[]) => items.map(bin => `* ${bin}`).join('\n')

const theCargoToml: CargoToml = parse(CargoToml, await $`yj -t < Cargo.toml`)
const { package: {name, description, metadata: {details: {title}}} } = theCargoToml
const { package: { name, description, metadata: { details: { title } } } } = theCargoToml
const bin = name
const help = await $`cargo run --quiet --bin ${bin} -- --help`
const repo: Repo = parse(Repo, await $`gh repo view --json url`)
const extraBins = (await $`find src/bin/*.rs -type f -exec basename {} .rs \\;`).valueOf().split("\n")
const extraBins = (await $`find src/bin/*.rs -type f -exec basename {} .rs \\;`).valueOf().split('\n')

assertEquals(repo.url, theCargoToml.package.repository)

Expand Down Expand Up @@ -73,17 +73,18 @@ ${bin} --name my-new-project --copy-configs-from ~/workspace/my-existing-project
${bin} --name my-new-project --dir ~/workspace/my-new-project
# Create a public repo
${bin} --name my-new-project --public
${bin} --name my-new-project --repo-create-cmd "gh repo create --public {{name}}"
# Create a lib instead of bin
${bin} --name my-new-project --cargo-init-args '--lib'
${bin} --name my-new-project --project-init-cmd "cargo init --lib"
\`\`\`
## Features
* Uses existing \`gh\`, \`git\`, \`cargo\` commands
* Forwards the flags to commands
* Can be used as a library
* [x] Uses existing \`gh\`, \`git\`, \`cargo\` commands
* [x] Supports overrides for all commands
* [x] Supports substitutions (see help below)
* [x] Can be used as a library
## Installation
Expand Down
2 changes: 1 addition & 1 deletion src/bin/create-rust-github-private-bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use create_rust_github_repo::CreateRustGithubRepo;

fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.project_init_cmd("gh repo create --private {{name}}")
.repo_create_cmd("gh repo create --private {{name}}")
.project_init_cmd("cargo init --bin")
.run()
}
2 changes: 1 addition & 1 deletion src/bin/create-rust-github-private-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use create_rust_github_repo::CreateRustGithubRepo;

fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.project_init_cmd("gh repo create --private {{name}}")
.repo_create_cmd("gh repo create --private {{name}}")
.project_init_cmd("cargo init --lib")
.run()
}
2 changes: 1 addition & 1 deletion src/bin/create-rust-github-public-bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use create_rust_github_repo::CreateRustGithubRepo;

fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.project_init_cmd("gh repo create --public {{name}}")
.repo_create_cmd("gh repo create --public {{name}}")
.project_init_cmd("cargo init --bin")
.run()
}
2 changes: 1 addition & 1 deletion src/bin/create-rust-github-public-lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use create_rust_github_repo::CreateRustGithubRepo;

fn main() -> anyhow::Result<()> {
CreateRustGithubRepo::parse()
.project_init_cmd("gh repo create --public {{name}}")
.repo_create_cmd("gh repo create --public {{name}}")
.project_init_cmd("cargo init --lib")
.run()
}

0 comments on commit cceecb2

Please sign in to comment.