{"id":13638284,"url":"https://github.com/anki-code/xontrib-dalias","last_synced_at":"2025-03-23T13:32:15.117Z","repository":{"id":245762808,"uuid":"819165131","full_name":"anki-code/xontrib-dalias","owner":"anki-code","description":"Library of decorator aliases (daliases) for @xonsh.","archived":false,"fork":false,"pushed_at":"2025-02-17T16:50:57.000Z","size":40,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T07:41:12.576Z","etag":null,"topics":["xonsh","xontrib"],"latest_commit_sha":null,"homepage":"","language":"Python","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/anki-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"anki-code"}},"created_at":"2024-06-24T00:43:19.000Z","updated_at":"2025-02-17T23:35:47.000Z","dependencies_parsed_at":"2024-07-19T14:17:37.336Z","dependency_job_id":"661eaab4-cd35-419e-8655-38ffdd088152","html_url":"https://github.com/anki-code/xontrib-dalias","commit_stats":null,"previous_names":["anki-code/xontrib-spec-mod","anki-code/xontrib-dalias"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-dalias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-dalias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-dalias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anki-code%2Fxontrib-dalias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anki-code","download_url":"https://codeload.github.com/anki-code/xontrib-dalias/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245108276,"owners_count":20562018,"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":["xonsh","xontrib"],"created_at":"2024-08-02T01:00:43.555Z","updated_at":"2025-03-23T13:32:15.101Z","avatar_url":"https://github.com/anki-code.png","language":"Python","funding_links":["https://github.com/sponsors/anki-code"],"categories":["Language extensions"],"sub_categories":["Prompt tweaks"],"readme":"\u003cp align=\"center\"\u003e\nLibrary of decorator aliases (daliases) for the xonsh shell.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nIf you like the idea click ⭐ on the repo and \u003ca href=\"https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!\u0026url=https://github.com/anki-code/xontrib-dalias\" target=\"_blank\"\u003etweet\u003c/a\u003e.\n\u003c/p\u003e\n\n\n## Installation\n\nTo install use pip:\n\n```xsh\nxpip install xontrib-dalias\n# or\nxpip install 'xontrib-dalias[dict,yaml]'  # With extra decorators.\n```\nLoad:\n```xsh\nxontrib load dalias\n```\n\n## Usage\n\n### Transform output to object\n\nDecorators:\n\n* Default:\n    * `@lines` - return list of lines.\n    * `@json` - json to Python `dict`.\n    * `@path` - string to [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html).\n    * `@parts` - split by whitespaces using xonsh lexer. It's the same as [builtin `@$()` operator](https://xon.sh/tutorial.html#command-substitution-with).\n* Extra (`xpip install 'xontrib-dalias[dict,yaml]'`):\n    * `@dict` - dict-like object (json, JavaScript object, Python dict) to Python `dict`. \n    * `@yaml` - YAML to Python `dict`.\n\n#### Examples\n```xsh\n$(@lines ls /)\n# ['/bin', '/etc', '/home']\n\n$(@json echo '{\"a\":1}')  # Try with `curl` ;)\n# dict({\"a\":1})\n\ndocker inspect @($(@json docker ps --format json)['ID'])\n# Container info\n\n$(@path which -s xonsh)\n# Path('/path/to/xonsh')\n\n$(@path which -s xonsh).parent\n# Path('/path/to')\n\n\naliases['ydig'] = '@yaml dig +yaml'  # Update `dig` via `brew install bind` to have `+yaml`.\ny = $(ydig google.com)\ny[0]['type']\n# 'MESSAGE'\n```\n\nPiping into decorated alias to get object:\n\n```xsh\n$(echo '{\"a\":1}' | @json cat)\n# dict({\"a\":1})\n```\n\n```xsh\naliases['@j'] = '@json cat'\n$(echo '{\"a\":1}' | @j)\n# dict({\"a\":1})\n```\n\n\n### Error handling\n\nDefault decorators:\n* `@err` - set `$RAISE_SUBPROC_ERROR=True` for the command.\n* `@noerr` - set `$RAISE_SUBPROC_ERROR=False` for the command.\n\nExamples:\n```xsh\n$RAISE_SUBPROC_ERROR = True  # General environment.\nif ![@noerr ls nononofile]:  # Do not raise exception in case of error.\n    echo file \n```\n\n## Credits\n\nThis package was created with [xontrib template](https://github.com/xonsh/xontrib-template).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxontrib-dalias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanki-code%2Fxontrib-dalias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanki-code%2Fxontrib-dalias/lists"}