{"id":13543286,"url":"https://github.com/markbates/grift","last_synced_at":"2025-05-16T04:03:42.373Z","repository":{"id":55067314,"uuid":"71397841","full_name":"markbates/grift","owner":"markbates","description":"Go based task runner","archived":false,"fork":false,"pushed_at":"2020-05-05T22:30:34.000Z","size":68,"stargazers_count":432,"open_issues_count":3,"forks_count":23,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-08T14:08:00.542Z","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/markbates.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-10-19T20:47:26.000Z","updated_at":"2025-02-11T21:32:55.000Z","dependencies_parsed_at":"2022-08-14T11:00:19.437Z","dependency_job_id":null,"html_url":"https://github.com/markbates/grift","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fgrift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fgrift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fgrift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fgrift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbates","download_url":"https://codeload.github.com/markbates/grift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"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":[],"created_at":"2024-08-01T11:00:28.669Z","updated_at":"2025-05-16T04:03:42.347Z","avatar_url":"https://github.com/markbates.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library"],"sub_categories":["任务/定时器","Task/Timer"],"readme":"# Grift\n\nGrift is a very simple library that allows you to write simple \"task\" scripts in Go and run them by name without having to write big `main` type of wrappers. Grift is similar to, and inspired by, [Rake](http://rake.rubyforge.org).\n\n## Why?\n\nExcellent question! When building applications there comes a point where you need different scripts to do different things. For example, you might want a script to seed your database, or perhaps a script to parse some logs, etc...\n\nGrift lets you write these scripts using Go in a really simple and extensible way.\n\n## Installation\n\nInstallation is really easy using `go get`.\n\n```text\n$ go get github.com/markbates/grift\n```\n\nYou can confirm the installation by running:\n\n```text\n$ grift jim\n```\n\n## Usage/Getting Started\n\nApart from having the binary installed, the only other requirement is that the package you place your grifts in is called `grifts`. That's it.\n\nBy running the following command:\n\n```text\n$ grift init\n```\n\nWhen you run the `init` sub-command Grift will generate a new `grifts` package and create a couple of simple grifts for you.\n\n#### List available grifts\n\n```text\n$ grift list\n```\n\n#### Say Hello!\n\n```text\n$ grift hello\n```\n\n## That's it!\n\nThat's really it! Grift is meant to be simple. Write your grifts, use the full power of Go to do it.\n\nFor more information I would highly recommend checking out the [docs](https://godoc.org/github.com/markbates/grift/grift).\n\n\n### Examples:\n\n```go\npackage grifts\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t. \"github.com/markbates/grift/grift\"\n)\n\nvar _ = Add(\"boom\", func(c *Context) error {\n\treturn errors.New(\"boom!!!\")\n})\n\nvar _ = Add(\"hello\", func(c *Context) error {\n\tfmt.Println(\"Hello World!\")\n\treturn nil\n})\n\nvar _ = Add(\"hello\", func(c *Context) error {\n\tfmt.Println(\"Hello World! Again\")\n\terr := Run(\"db:migrate\", c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdir, err := os.Getwd()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"### dir -\u003e %+v\\n\", dir)\n\treturn nil\n})\n\nvar _ = Add(\"env:print\", func(c *Context) error {\n\tif len(c.Args) \u003e= 1 {\n\t\tfor _, e := range c.Args {\n\t\t\tfmt.Printf(\"%s=%s\\n\", e, os.Getenv(e))\n\t\t}\n\t} else {\n\t\tfor _, e := range os.Environ() {\n\t\t\tpair := strings.Split(e, \"=\")\n\t\t\tfmt.Printf(\"%s=%s\\n\", pair[0], os.Getenv(pair[0]))\n\t\t}\n\t}\n\n\treturn nil\n})\n\nvar _ = Namespace(\"db\", func() {\n    Desc(\"migrate\", \"Migrates the databases\")\n    Set(\"migrate\", func(c *Context) error {\n            fmt.Println(\"db:migrate\")\n            fmt.Printf(\"### args -\u003e %+v\\n\", c.Args)\n            return nil\n    })\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fgrift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbates%2Fgrift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fgrift/lists"}