Skip to content

Add cowsay command#65

Merged
jiacai2050 merged 5 commits intomainfrom
copilot/add-cowsay-command
Mar 16, 2026
Merged

Add cowsay command#65
jiacai2050 merged 5 commits intomainfrom
copilot/add-cowsay-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

Implements cowsay as a new CLI binary — renders a speech bubble around a message and prints ASCII cow (or Tux penguin) art below it.

Changes

  • src/bin/cowsay.zig: New binary with:
    • writeSpeechBubble: single-line uses < text >, multi-line uses /, |, \ side borders with padding to align all lines
    • Two built-in cow faces via -f/--face enum flag: cow (default) and tux
    • Positional args joined with spaces as the message
    • Unit tests for single-line, two-line, and three-line bubble rendering
  • build.zig: Registers cowsay in the binary list (auto-wires run-cowsay, install-cowsay, test-cowsay)

Usage

$ cowsay hi
 ____
< hi >
 ----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

$ cowsay -f tux hi
 ____
< hi >
 ----
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ziglang.org
    • Triggering command: /usr/bin/wget wget -q REDACTED -O zig.tar.xz (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>implement new command: cowsay</issue_title>
<issue_description>```
$ cowsay hi


< hi >

    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||

$ cowsay -f tux hi


< hi >



.--.
|o_o |
|:_/ |
// \
(| | )
/'_ /`
_)=(
/

- https://en.wikipedia.org/wiki/Cowsay</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 16, 2026 03:18
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new command: cowsay Add cowsay command Mar 16, 2026
Copilot AI requested a review from jiacai2050 March 16, 2026 03:28
@jiacai2050 jiacai2050 marked this pull request as ready for review March 16, 2026 03:34
Copilot AI review requested due to automatic review settings March 16, 2026 03:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new cowsay CLI binary to the ZigCLI suite, providing classic cowsay-style output (speech bubble + ASCII art) with a selectable face.

Changes:

  • Introduces src/bin/cowsay.zig implementing bubble rendering and -f/--face selection (cow/tux), plus unit tests.
  • Registers the new cowsay binary in build.zig so it participates in install/run/test steps.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
src/bin/cowsay.zig New cowsay command implementation, includes bubble rendering logic and tests.
build.zig Adds cowsay to the binaries list so it is built and tested.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@jiacai2050
Copy link
Copy Markdown
Owner

@copilot 修复ci的错误

…rors

Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot 修复ci的错误

Fixed in 4ec7ba1. The issue was that writeSpeechBubble declared writer: *std.Io.Writer, but tests pass a GenericWriter from ArrayList.writer() which is a different concrete type and can't coerce. Changed the parameter to anytype (the idiomatic Zig approach, also used by simargs.printHelp) so it accepts both the *std.Io.Writer from main and the GenericWriter in tests.

@jiacai2050
Copy link
Copy Markdown
Owner

@copilot 增加对应文档

Co-authored-by: jiacai2050 <3848910+jiacai2050@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 16, 2026

@copilot 增加对应文档

Added in 1915599 — created docs/content/programs/cowsay.org following the same Org-mode format as other commands in the docs, with the help output and demo examples.

@jiacai2050 jiacai2050 merged commit e5f3a9b into main Mar 16, 2026
@jiacai2050 jiacai2050 deleted the copilot/add-cowsay-command branch March 16, 2026 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement new command: cowsay

3 participants