Skip to content

bobadilla-tech/lorelai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lorelai

PkgGoDev CodeQL Go Report Card

A package and command line tool to generate Lorem ipsum.

Cover

Blog explaining this package

Checkout the code coverage at: https://bobadilla-tech.github.io/lorelai

Install

go get github.com/bobadilla-tech/lorelai/pkg

Examples

Generating Text

func printTonsOfText() {
	for i := 0; i < 10; i++ {
          fmt.Println(lorelai.Paragraph())
	}
}

Structured Text Generation

func generateStructuredContent() {
	// Generate 3 paragraphs with 5 sentences each
	result := lorelai.Generate(3, 5)
	fmt.Println(result.Text)
	fmt.Printf("Generated %d words across %d paragraphs\n",
		result.WordCount, result.Paragraphs)
}

func generateClassicLorem() {
	// Generate classic Lorem Ipsum text
	result := lorelai.ClassicGenerate(2, 4)
	fmt.Println(result.Text)
}

Convenience Utilities

func sayHi() {
	fmt.Printf("My, my name is: %s.\n", lorelai.Word())
	fmt.Printf("My email address is %s\n", lorelai.Email())
	fmt.Printf("My website is: %s\n", lorelai.URL())
}

For more examples check the examples directory.

Documentation

Core Text Generation Functions

Random Lorem Ipsum:

  • Word: Returns 1 random word E.g: "sodales", "phasellus", "diam"

  • Sentence: Returns 8 random words (1 sentence) E.g: "Varius sed imperdiet amet laoreet ex sapien placerat."

  • Paragraph: Returns 45 random words (1 paragraph) E.g: "Nisi lacinia ante non nunc eros nibh mattis enim orci ante in ornare accumsan..."

  • Generate: Generate structured text with X paragraphs of Y sentences each Returns: Lorem{Text, Paragraphs, Sentences, WordCount} E.g: Generate(3, 5) creates 3 paragraphs with 5 sentences each (120 words)

Classic Lorem Ipsum:

  • ClassicSentence: Returns 8 words from classic text Always starts with "Lorem ipsum dolor sit amet..."

  • ClassicParagraph: Returns full classic Lorem paragraph The traditional Lorem Ipsum text

  • ClassicGenerate: Generate classic text with X paragraphs of Y sentences each Returns: Lorem{Text, Paragraphs, Sentences, WordCount} E.g: ClassicGenerate(2, 4) creates 2 paragraphs with 4 classic sentences each

  • ClassicWords: Returns N words from classic text

Word Generation Functions

  • LoremWords: Returns N random words E.g: "arcu", "blandit porttitor a scelerisque", "donec justo lacinia"

  • FormattedLoremWords: Returns N words with capitalization and period E.g: "Libero malesuada duis massa luctus.", "Curabitur hendrerit sed."

Convenience Utilities

CLI Tool

Installation

go install github.com/bobadilla-tech/lorelai@latest

Or use a binary from releases.

Usage

If you don't pass any flag or you pass the help flag:

 lorelai 1.0.0
 Easily generate Lorem Ipsum on command line.

 -h or --help           Print this

 -w or --word           Number of words to print

 -p or --paragraph      Number of paragraphs to print

 -s or --sentences      Number of sentences to print

 -o or --output         If passed it will try to put the output in a file

 --url                  A random URL

 --email                A random Email Address

 --color                Print the output with colors?

  Examples:
      lorelai -w 55           # Will print 55 words
      lorelai -p 5            # Will print 5 paragraphs
      lorelai -s 5 --output b # Will write 5 sentences on file b if possible
      lorelai -w 55 -s 5      # Will print 55 words and 5 sentences

 If you need more help, found a bug or want to suggest a new feature:
 https://github.com/bobadilla-tech/lorelai

Contributing

Feel free to suggest new features or report bugs.

A big thanks to Antoineio for adding tests and contributing to the CI.

License

This project is licensed under the MIT License.