{"id":34176870,"url":"https://github.com/origadmin/adptool","last_synced_at":"2026-03-13T04:32:00.192Z","repository":{"id":311221564,"uuid":"1033195381","full_name":"origadmin/adptool","owner":"origadmin","description":null,"archived":false,"fork":false,"pushed_at":"2025-12-29T21:31:33.000Z","size":534,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-02T04:25:57.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/origadmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-06T12:47:36.000Z","updated_at":"2025-12-29T21:31:37.000Z","dependencies_parsed_at":"2025-08-22T22:53:17.061Z","dependency_job_id":"f6463b18-680a-4014-9c73-b25e62ecb171","html_url":"https://github.com/origadmin/adptool","commit_stats":null,"previous_names":["origadmin/adptool"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/origadmin/adptool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origadmin%2Fadptool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origadmin%2Fadptool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origadmin%2Fadptool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origadmin%2Fadptool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/origadmin","download_url":"https://codeload.github.com/origadmin/adptool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origadmin%2Fadptool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30457998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T03:55:51.346Z","status":"ssl_error","status_checked_at":"2026-03-13T03:55:33.055Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-12-15T12:58:56.064Z","updated_at":"2026-03-13T04:32:00.185Z","avatar_url":"https://github.com/origadmin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adptool\n\n[![CI](https://github.com/origadmin/adptool/actions/workflows/ci.yml/badge.svg)](https://github.com/origadmin/adptool/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/origadmin/adptool)](https://github.com/origadmin/adptool/releases/latest)\n[![Go Report Card](https://goreportcard.com/badge/github.com/origadmin/adptool)](https://goreportcard.com/report/github.com/origadmin/adptool)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`adptool` is a powerful and highly configurable Go code generator that automates the creation of adapter code. It helps\nyou seamlessly integrate third-party libraries and internal modules by generating type aliases, function wrappers, and\nmethod proxies based on a clear and powerful configuration system.\n\n## Core Features\n\n- **Automated Adapter Generation**: Eliminates boilerplate code by automatically generating type-safe adapters.\n- **Flexible Configuration**: Use YAML, JSON, or TOML to define your code generation rules.\n- **Hierarchical Rule System**: Apply rules globally, per-package, or for specific types, functions, and members.\n- **Granular Renaming Control**: Precisely control naming with prefixes, suffixes, regular expressions, and explicit\n  from/to mappings.\n- **Simple Source-Code Directives**: Use simple `//go:adapter` comments to mark packages for adaptation without\n  cluttering your code.\n- **Dependency Decoupling**: Isolate your core logic from specific third-party implementations, making upgrades and\n  replacements easier.\n\n## Installation\n\n#### From Source\n\n```bash\ngo install github.com/origadmin/adptool/cmd/adptool@latest\n```\n\n#### Pre-compiled Binaries\n\nVisit the [**Releases Page**](https://github.com/origadmin/adptool/releases) to download a pre-compiled binary for your\nplatform.\n\n---\n\n## Quick Start\n\nLet's adapt a fictional third-party library `github.com/foo/bar` into our project.\n\n**1. Add a Directive**\n\nCreate a file (e.g., `adapters/directives.go`) to tell `adptool` which package you want to adapt.\n\n```go\n// adapters/directives.go\n\npackage myapp\n\n//go:adapter:package github.com/foo/bar\n```\n\n**2. Create a Configuration File**\n\n`adptool` needs rules to work. Create an `.adptool.yaml` file in your project root.\n\n```yaml\n# .adptool.yaml\n\n# Set the package name for the generated file.\npackage_name: \"myapp\"\n\n# Define a global rule: add the prefix \"MyApp_\" to all types from the adapted package.\ntypes:\n  - prefix: \"MyApp_\"\n```\n\n**3. Run adptool**\n\nExecute the tool, pointing it to the directory containing your directive file.\n\n```bash\nadptool ./adapters\n```\n\n**4. Get the Generated Code**\n\n`adptool` will create a new file `adapters/generate.adapter.go` in the same directory, containing the adapted code:\n\n```go\n// Code generated by adptool. DO NOT EDIT.\n//\n// This file is generated from directives.go.\n\n// Package myapp contains generated code by adptool.\npackage myapp\n\nimport (\n\tbar \"github.com/foo/bar\"\n)\n\n// Renamed from \"Client\" with the \"MyApp_\" prefix.\ntype MyApp_Client = bar.Client\n\n// Renamed from \"Config\" with the \"MyApp_\" prefix.\ntype MyApp_Config = bar.Config\n\n// ... and so on for all other types in the package.\n```\n\n---\n\n## Usage\n\n### Command-Line Interface (CLI)\n\n```sh\nadptool [flags] [arguments...]\n```\n\n**Arguments**\n\n- `[arguments...]` (required): One or more Go source files or directories to scan for directives. Supports `...`\n  wildcard syntax (e.g., `./...`).\n\n**Flags**\n\n- `-c, --config \u003cfile_path\u003e`\n    - Specifies the path to a configuration file (YAML, JSON, or TOML). If not provided, `adptool` automatically\n      searches for `.adptool.yaml` (or `.json`, `.toml`) in the current directory and a `./configs` subdirectory.\n\n- `--copyright-holder \u003cstring\u003e`\n    - Injects a copyright notice into the generated file's header.\n\n- `-o, --output \u003cfile_path\u003e` (Planned)\n    - Specifies a single file path for all generated output code. Currently, output files are generated automatically\n      alongside their source directive files.\n\n- `-v, --verbose` (Planned)\n    - Enables verbose logging for debugging.\n\n### Directives\n\nDirectives are comments in your Go source code that `adptool` uses as entry points.\n\n- `//go:adapter:package \u003cimport_path\u003e [alias]`\n    - This is the primary directive. It tells `adptool` to adapt the package specified by `\u003cimport_path\u003e`.\n    - You can optionally provide a custom `[alias]` for the package in the generated code.\n\n  ```go\n  // Adapt the package, letting the generator create an alias.\n  //go:adapter:package github.com/spf13/viper\n\n  // Adapt the package and give it a specific alias.\n  //go:adapter:package github.com/google/uuid custom_uuid\n  ```\n\n## Configuration\n\n`adptool` is controlled by a configuration file (e.g., `.adptool.yaml`). For fully-commented examples, see the [*\n*`./examples`**](./examples) directory.\n\nHere is a high-level overview of the main configuration sections:\n\n- `package_name`: Sets the package name for the generated file.\n- `ignores`: A list of symbol names to exclude from generation. Supports wildcards (`*`).\n- `defaults`: Sets the default behavior for how rules are applied (e.g., `prepend` or `replace` for prefixes).\n- `props`: A list of key-value pairs that can be used as variables in other parts of the configuration.\n- `packages`: A list of package-specific rules that override the global rules.\n- `types`, `functions`, `variables`, `constants`: These sections contain the core renaming rules for different kinds of\n  Go declarations.\n\n### Rule Priority\n\nFor any given symbol, rules are resolved and applied in the following order:\n\n1. **Ignore**: If a symbol matches an `ignores` rule, it is skipped entirely.\n2. **Explicit**: If an `explicit` rule (`from`/`to`) matches the symbol, it is renamed, and **no further rules apply**.\n3. **Prefix \u0026 Suffix**: If no explicit rule matches, the resolved `prefix` and `suffix` are applied.\n4. **Regex**: The resolved `regex` rules are applied to the result of the previous step.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit an Issue or Pull Request.\n\n## License\n\n`adptool` is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigadmin%2Fadptool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forigadmin%2Fadptool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigadmin%2Fadptool/lists"}