{"id":16856417,"url":"https://github.com/vallentin/metro","last_synced_at":"2025-04-11T07:39:27.718Z","repository":{"id":57638340,"uuid":"241113729","full_name":"vallentin/metro","owner":"vallentin","description":"Metro is a crate for creating and rendering graphs similar to `git log --graph`","archived":false,"fork":false,"pushed_at":"2020-10-02T17:39:57.000Z","size":57,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T05:11:29.220Z","etag":null,"topics":["graph","pretty-print","rust","rust-crate","rust-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vallentin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-17T13:25:32.000Z","updated_at":"2021-01-29T07:29:14.000Z","dependencies_parsed_at":"2022-09-26T20:20:42.397Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/metro","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fmetro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fmetro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fmetro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fmetro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/metro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248359150,"owners_count":21090481,"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":["graph","pretty-print","rust","rust-crate","rust-library"],"created_at":"2024-10-13T14:04:11.396Z","updated_at":"2025-04-11T07:39:27.697Z","avatar_url":"https://github.com/vallentin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metro\n\n[![Build Status](https://github.com/vallentin/metro/workflows/Rust/badge.svg)](https://github.com/vallentin/metro/actions?query=workflow%3ARust)\n[![Build Status](https://travis-ci.org/vallentin/metro.svg?branch=master)](https://travis-ci.org/vallentin/metro)\n[![Latest Version](https://img.shields.io/crates/v/metro.svg)](https://crates.io/crates/metro)\n[![Docs](https://docs.rs/metro/badge.svg)](https://docs.rs/metro)\n[![License](https://img.shields.io/github/license/vallentin/metro.svg)](https://github.com/vallentin/metro)\n\nMetro is a crate for creating and rendering graphs\nsimilar to `git log --graph`.\n\nFor a `git log --graph` example, see [examples/git2.rs](examples/git2.rs).\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nmetro = \"0.1\"\n```\n\n## TODOs\n\n- [ ] Colors and themes\n- [ ] Iterator to stream output line by line\n\n## Releases\n\nRelease notes are available in the repo at [CHANGELOG.md].\n\n[CHANGELOG.md]: CHANGELOG.md\n\n## Example Output\n\n*The code for creating the following example, can be found\nafter the graph.*\n\n```text\n* Station 1\n* Station 2\n* Station 3\n|\\\n| * Station 4\n| |\\\n| * | Station 5\n| | * Station 6\n* | | Station 7\n| * | Station 8\n| | * Station 9\n| | |\\\n| | | |\\\n| | | | | Station 10 (Detached)\n| |_|_|/\n|/| | |\n| | | * Station 11\n| \" | |\n|  / /\n* | | Station 12\n| * | Station 13\n| | * Station 14\n| |/\n|/|\n| * Station 15\n| \"\n* Station 16\n```\n\n## Example Using `Metro`\n\n*The following example outputs the graph above.*\n\n```rust\nuse metro::Metro;\n\nlet mut metro = Metro::new();\n\nlet mut track1 = metro.new_track();\ntrack1.add_station(\"Station 1\");\ntrack1.add_station(\"Station 2\");\ntrack1.add_station(\"Station 3\");\n\nlet mut track2 = track1.split();\ntrack2.add_station(\"Station 4\");\n\nlet mut track3 = track2.split();\ntrack2.add_station(\"Station 5\");\ntrack3.add_station(\"Station 6\");\n\ntrack1.add_station(\"Station 7\");\ntrack2.add_station(\"Station 8\");\ntrack3.add_station(\"Station 9\");\n\nlet mut track4 = track3.split();\nlet track5 = track4.split();\n\nmetro.add_station(\"Station 10 (Detached)\");\n\ntrack5.join(\u0026track1);\n\ntrack4.add_station(\"Station 11\");\n\ntrack2.stop();\n\ntrack1.add_station(\"Station 12\");\ntrack3.add_station(\"Station 13\");\ntrack4.add_station(\"Station 14\");\n\ntrack4.join(\u0026track1);\n\ntrack3.add_station(\"Station 15\");\n\ntrack3.stop();\n\ntrack1.add_station(\"Station 16\");\n\nlet string = metro.to_string().unwrap();\n\nprintln!(\"{}\", string);\n```\n\n## Example Using `Event`\n\n*The following example outputs the graph above.*\n\n```rust\nuse metro::Event;\n\nlet events = [\n    Event::station(0, \"Station 1\"),\n    Event::station(0, \"Station 2\"),\n    Event::station(0, \"Station 3\"),\n    Event::SplitTrack(0, 1),\n    Event::station(1, \"Station 4\"),\n    Event::SplitTrack(1, 2),\n    Event::station(1, \"Station 5\"),\n    Event::station(2, \"Station 6\"),\n    Event::station(0, \"Station 7\"),\n    Event::station(1, \"Station 8\"),\n    Event::station(2, \"Station 9\"),\n    Event::SplitTrack(2, 3),\n    Event::SplitTrack(3, 4),\n    Event::station(5, \"Station 10 (Detached)\"),\n    Event::JoinTrack(4, 0),\n    Event::station(3, \"Station 11\"),\n    Event::StopTrack(1),\n    Event::station(0, \"Station 12\"),\n    Event::station(2, \"Station 13\"),\n    Event::station(3, \"Station 14\"),\n    Event::JoinTrack(3, 0),\n    Event::station(2, \"Station 15\"),\n    Event::StopTrack(2),\n    Event::station(0, \"Station 16\"),\n];\n\nlet string = metro::to_string(\u0026events).unwrap();\n\nprintln!(\"{}\", string);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fmetro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fmetro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fmetro/lists"}