{"id":16226341,"url":"https://github.com/shaozi/cowsay","last_synced_at":"2025-03-19T13:30:39.734Z","repository":{"id":247526415,"uuid":"826093757","full_name":"shaozi/cowsay","owner":"shaozi","description":"🐮 🐮 🐮 A simple library generates an ascii cow says a message. 🐮 🐮 🐮","archived":false,"fork":false,"pushed_at":"2024-08-12T01:07:39.000Z","size":36,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T18:47:27.749Z","etag":null,"topics":["beginner","fun","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shaozi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-09T05:14:50.000Z","updated_at":"2024-08-12T01:07:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"a98ae2d0-7413-4cda-831d-f1634cebda95","html_url":"https://github.com/shaozi/cowsay","commit_stats":null,"previous_names":["shaozi/cowsay"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaozi%2Fcowsay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaozi%2Fcowsay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaozi%2Fcowsay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaozi%2Fcowsay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaozi","download_url":"https://codeload.github.com/shaozi/cowsay/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989577,"owners_count":20379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beginner","fun","zig"],"created_at":"2024-10-10T12:48:48.303Z","updated_at":"2025-03-19T13:30:39.468Z","avatar_url":"https://github.com/shaozi.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cowsay\n\nThis is a simple zig library that mimic the ascii art [**cowsay**](https://en.wikipedia.org/wiki/Cowsay) .\n\n## What's New\n\n[x] Support UTF-8\n\n## Install\n\n1. Use the `zig fetch` command to fetch and save the library:\n   - Fetch the latest: `zig fetch --save git+https://github.com/shaozi/cowsay`\n   - or, fetch a specific version: `zig fetch --save https://github.com/shaozi/cowsay/archive/refs/tags/v3.0.0.tar.gz`\n1. Add the module to you own `build.zig` file:\n\n   - Add these lines right before the line `b.installArtifact(exe);`:\n\n     ```zig\n     const Cowsay = b.dependency(\"Cowsay\", .{});\n     exe.root_module.addImport(\"Cowsay\", Cowsay.module(\"Cowsay\"));\n     ```\n\n1. Import it in your zig file:\n\n   ```zig\n   const Cowsay = @import(\"Cowsay\");\n   ```\n\n## Usage\n\n### Basic usage\n\n```zig\nconst stdout = std.io.getStdOut().writer();\nvar gpa = std.heap.GeneralPurposeAllocator(.{}){};\n\ndefer {\n   const deinit_status = gpa.deinit();\n   //fail test; can't try in defer as defer is executed after we return\n   if (deinit_status == .leak) @panic(\"TEST FAIL\");\n}\nvar cow = Cowsay.init(gpa.allocator, stdout.any());\ndefer cow.deinit();\ntry cow.say(\"Hello {s}\", .{\"world!\"});\n```\n\nOutput:\n\n```text\n+--------------+\n| Hello world! |\n+--------------+\n        \\ ^__^\n         \\(oo)\\_______\n          (__)\\       )\\/\\\n              ||----w |\n              ||     ||\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e Cowsay takes type `std.io.AnyWriter`. Therefore, you must use the `.any()` to\n\u003e convert a writer before pass it in. This allows you to use an ArrayList(u8) to\n\u003e let cowsay write output to a string.\n\n### Eyes\n\n```zig\ncow.eyes = [_]u8{ '$', '$' };\n```\n\nOutput:\n\n```text\n+--------------+\n| Hello world! |\n+--------------+\n        \\ ^__^\n         \\($$)\\_______\n          (__)\\       )\\/\\\n              ||----w |\n              ||     ||\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e The first two `o` in the file are eyes.\n\n### Load an ASCII cow file\n\n```zig\ntry cow.useCowFile(\"cat\");\n```\n\nOutput\n\n```text\n+-------------+\n| Hello meow! |\n+-------------+\n       \\  /\\___/\\\n        \\(= ^.^ =)\n          (\") (\")__/\n```\n\nand use the default cow:\n\n```zig\ncow.useDefaultCow();\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e - Cow file is simple text file of the ascii image, without the `\\` bubble pointer.\n\u003e - Max length of the file is 1000 bytes.\n\n### Cow think\n\n```zig\ntry cow.think(\"Hmm... Hello ... world ...\", .{});\n```\n\nOutput\n\n```text\n+----------------------------+\n| Hmm... Hello ... world ... |\n+----------------------------+\n               o  ^__^\n                o (oo)\\_______\n                  (__)\\       )\\/\\\n                      ||----w |\n                      ||     ||\n```\n\n### Write to an `ArrayList`, out as a string\n\n```zig\nvar buffer = std.ArrayList(u8).init(std.heap.page_allocator);\ndefer buffer.deinit();\nconst w = buffer.writer().any();\nvar cow = Cowsay.init(allocator, w);\ndefer cow.deinit();\ntry cow.say(\"Hello world!\", .{});\ntry stdout.print(\"{s}\", buffer.items);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaozi%2Fcowsay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaozi%2Fcowsay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaozi%2Fcowsay/lists"}