Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Last active September 12, 2024 02:58
Show Gist options
  • Save wilmoore/a216fdba9cc8466abcba061b35e311f1 to your computer and use it in GitHub Desktop.
Save wilmoore/a216fdba9cc8466abcba061b35e311f1 to your computer and use it in GitHub Desktop.
Writing :: Books :: » book

Writing :: Books :: book

⪼ Made with 💜 by Polyglot.

related

» book

Book Publishing Automation

» echo -e 'PUBLISHER="Shower Thought Publishing"\nTITLE="Why You _Should_ Write Your Book ... in Markdown!"\nISBN=""\nPERSPECTIVE=EXPERT|SELF\nAUDIOBOOK=true\nEBOOK=true\SELF_PUBLISH=true\nDRAFT=true' > .env
» direnv allow
» book init \
  --title "$TITLE" \
  --publisher "$PUBLISHER" \
  --isbn $ISBN \
  --draft $DRAFT
 » book publish

readme.md

Features

The book command-line tool allows users to initialize and publish books easily. This documentation will guide you through its usage, options, and subcommands.

Synopsis

book [global-options] <subcommand> [subcommand-options]

Global Options

  • --help - Display the help message.
  • --version - Show the version number of the book tool.

Subcommands

1. init

Initialize a new book in the current directory.

» book init [book-name]

Options:

  • book-name - Optional. The name of your book. If not provided, you'll be prompted for it.

Examples:

Initialize a new book with the name "Why You Should Write Your Book ... in Markdown!"

» book init --title "Why You _Should_ Write Your Book ... in Markdown!" --publisher[-imprint]=$PUBLISHER_NAME

2. publish

Publish the current book to a specific publisher.

» book publish --publisher=$PUBLISHER_NAME

Options:

  • --publisher, --publisher-imprint - The name of the publisher to which you want to publish the book. This option is required for the publish subcommand.

Examples:

Publish the current book to "Shower Thought Publishing":

» book publish --publisher="Shower Thought Publishing"

SDK Command Examples

TypeScript

Before diving into the TypeScript example, ensure you've set up the necessary typings for the book SDK.

Declaration file (book.d.ts):

declare module "book-sdk" {
  interface InitOptions {
    bookName?: string;
  }

  interface PublishOptions {
    publisher: string;
  }

  function init(options?: InitOptions): Promise<void>;
  function publish(options: PublishOptions): Promise<void>;
}

Usage:

import { init, publish } from "book-sdk";

// Initialize a new book
init({ title: "Why You _Should_ Write Your Book ... in Markdown!" });

// Publish the book to a specific publisher
publish({ publisher: "Shower Thought Publishing" });

Python

Ensure you've installed the book-sdk for Python.

Usage:

from book_sdk import init, publish

# Initialize a new book
init(title="Why You _Should_ Write Your Book ... in Markdown!")

# Publish the book to a specific publisher
publish(publisher="Shower Thought Publishing")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment