Skip to content

bengarrett/sauce

Repository files navigation

Go Reference   Go Report Card Coverage

Package sauce

Package sauce is a Go module that parses SAUCE (Standard Architecture for Universal Comment Extensions) metadata.

Features

  • Parse SAUCE metadata from files
  • Extract comprehensive file information (title, author, group, date, etc.)
  • Support multiple file types and data types
  • Extract type-specific information
  • Parse comment blocks
  • Serialize to JSON format
  • Format dates and sizes for human readability
  • Provide comprehensive error handling

The Standard Architecture for Universal Comment Extensions, or SAUCE as it is more commonly known, is an architecture or protocol for attaching metadata or comments about files. Primarily designed for ANSI art files, SAUCE supports many different file types.

For the complete specification see:
http://www.acid.org/info/sauce/sauce.htm
https://github.com/radman1/sauce

Quick usage

Go Package with docs and examples.

// Open a file
file, err := os.Open("artwork.ans")
if err != nil {
    log.Fatal(err)
}
defer file.Close()

// Read the file and create a SAUCE record
sr, err := sauce.Read(file)
if err != nil {
    log.Println(err)
    return
}

// print specific SAUCE fields
fmt.Printf("%q\n", sr.Title)
fmt.Printf("Author:\t%s.\n", sr.Author)
fmt.Printf("Group:\t%s.\n", sr.Group)
fmt.Printf("Date:\t%s.\n", sr.Date.Time.Format(time.ANSIC))

// print the SAUCE data as indented JSON
js, err := sr.JSONIndent("  ")
if err != nil {
    log.Println(err)
    return
}
fmt.Printf("%s", js)

SAUCE as an API reference

  • id
    SAUCE identification. This should be equal to SAUCE.

  • version
    SAUCE version number, should be 00.

  • title
    Title of the file.

  • author
    The nick, name or handle of the creator of the file.

  • group
    The name of the group or company the creator is employed by.

  • date - The date the file was created.

    • value - SAUCE date format, CCYYMMDD (century, year, month, day).
    • iso - value as an ISO 8601 date.
    • epoch- value as Unix time, the number of seconds since 1 Jan 1970.
  • fileSize

    • bytes - The reported file size not including the SAUCE information.
    • decimal - bytes returned as a base 10 value (kilo, mega...).
    • binary - bytes returned as a base 2 value (kibi, mebi...).
  • dataType - Type of data.

    • type - DataType value.
    • name - DataType name.
  • fileType - Type of file.

    • type - FileType value.
    • name - FileType name.
  • typeInfo - Type-dependent information, see http://www.acid.org/info/sauce/sauce.htm#FileType

    • 1
      • value - Value of TInfo1
      • info - Human-readable description of the value
    • 2
      • value - Value of TInfo2
      • info - Human-readable description of the value
    • 3
      • value - Value of TInfo3
      • info - Human-readable description of the value
  • flags - Type-dependent flags

    • decimal - Value as an unsigned integer
    • binary - Value in binary notation
    • nonBlinkMode - Request ANSI non-blink mode (iCE Color)
      • flag - Value as binary bit boolean ("0" or "1")
      • interpretation - Human-readable description of the value
    • letterSpacing - ANSI letter-spacing to request 8 or 9 pixel font selection
      • flag - Value as a 2-bit binary string ("00", "01", "10")
      • interpretation - Human-readable description of the value
    • aspectRatio - ANSI aspect ratio to request LCD square or CRT monitor style pixels
      • flag - Value as a 2-bit binary string ("00", "01", "10")
      • interpretation - Human-readable description of the value
  • fontName - The creator's preferred font to view the ANSI artwork, see http://www.acid.org/info/sauce/sauce.htm#FontName

  • comments - Comments or notes from the creator

    • id - SAUCE comment block identification, this should be "COMNT"
    • count - The reported number of lines in the SAUCE comment block
    • lines - Lines of text, each line should comprise 64 characters

Similar projects and languages

About

Package sauce is a Go module that parses SAUCE metadata.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors