{"id":24515657,"url":"https://github.com/desktop-dart/dscript","last_synced_at":"2026-05-14T12:34:08.378Z","repository":{"id":91605442,"uuid":"114537619","full_name":"desktop-dart/dscript","owner":"desktop-dart","description":"Execute standalone Dart shell scripts","archived":false,"fork":false,"pushed_at":"2019-11-20T11:21:08.000Z","size":16,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T00:03:01.408Z","etag":null,"topics":["dartlang","scripting","scripting-language","shell","shell-script","standalone"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/desktop-dart.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-17T13:17:33.000Z","updated_at":"2022-02-21T20:31:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"06096392-4aca-46e8-b40d-415273400bb6","html_url":"https://github.com/desktop-dart/dscript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/desktop-dart/dscript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desktop-dart%2Fdscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desktop-dart%2Fdscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desktop-dart%2Fdscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desktop-dart%2Fdscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desktop-dart","download_url":"https://codeload.github.com/desktop-dart/dscript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desktop-dart%2Fdscript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33025110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["dartlang","scripting","scripting-language","shell","shell-script","standalone"],"created_at":"2025-01-22T01:18:45.357Z","updated_at":"2026-05-14T12:34:08.349Z","avatar_url":"https://github.com/desktop-dart.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dscript\n\nExecute standalone Dart shell scripts\n\n**Note**: Fork of [mezoni](https://github.com/mezoni)'s [dartx](https://github.com/mezoni/dartx). Special thanks to him!\n\n# Installation\n\n`dscript` can be using pub:\n\n```bash\npub global activate dscript\n```\n\nMake sure, it is installed in your path:\n\n```bash\ndscript version\n```\n\nLookup `dscript` command documentation:\n\n```bash\ndscript help\n```\n\n# Usage\n\n## Execute standalone Dart script\n\nCreate a Dart standalone script:\n\n**list.dart**\n```dart\nimport 'dart:io';\n\nmain() async {\n  final dir = Directory.current;\n\n  await for(FileSystemEntity entity in dir.list()) {\n    final FileStat stat = await entity.stat();\n    if(stat.type == FileSystemEntityType.FILE) {\n      print(entity.uri.pathSegments.last);\n    } else if (stat.type == FileSystemEntityType.DIRECTORY) {\n      print(entity.uri.pathSegments.reversed.elementAt(1));\n    }\n  }\n}\n```\n\nExecute it:\n\n```bash\ndscript list.dart\n```\n\nThe following screen cast shows how to execute a Dart standalone shell script using `dscript`: \n\n[![asciicast](https://asciinema.org/a/153020.png?size=small)](https://asciinema.org/a/153020)\n\n## Embedded pubspec\n\n`dscript` allows embedding pubspec in the scripts itself.\n\n```dart\n/*\n@pubspec.yaml\nname: list\n */\n\nimport 'dart:io';\n\nmain() async {\n  final dir = Directory.current;\n\n  await for(FileSystemEntity entity in dir.list()) {\n    final FileStat stat = await entity.stat();\n    if(stat.type == FileSystemEntityType.FILE) {\n      print(entity.uri.pathSegments.last);\n    } else if (stat.type == FileSystemEntityType.DIRECTORY) {\n      print(entity.uri.pathSegments.reversed.elementAt(1));\n    }\n  }\n}\n```\n\nExecute it:\n\n```bash\ndscript list.dart\n```\n\n## Scripts with dependencies\n\nWe can leverage embedded pubspec to use external packages from pub.dartlang.org or github.  \n\n**ok.dart**\n```dart\n/*\n@pubspec.yaml\nname: ok\ndependencies:\n  zenity:\n*/\n\nimport 'package:zenity/zenity.dart';\n\nmain() async {\n  final bool isOk = await Zenity.showQuestionMessage(\n      title: 'Hello!', text: 'Are you feeling ok?');\n  if(isOk) print(':)');\n  else print(':(');\n}\n```\n\nExecute it:\n\n```bash\ndscript ok.dart\n```\n\n[![asciicast](https://asciinema.org/a/153072.png?size=small)](https://asciinema.org/a/153072)\n\n## Multi file scripts\n\n**math.dart**\n```dart\n/*\n@pubspec.yaml\nname: calc\n*/\n\nimport 'dart:io';\nimport 'package:calc/calc.dart';\n\nvoid printUsage() {\n  print('calc arg1 operator arg2');\n  print('Supported operators:');\n  print('  + : Addition');\n  print('  - : Subtraction');\n  print('  * : Multiplication');\n  print('  / : Division');\n}\n\nmain(List\u003cString\u003e arguments) {\n  if(arguments.length != 3) {\n    printUsage();\n    exit(1);\n  }\n\n  final int a = int.parse(arguments[0]);\n  final int b = int.parse(arguments[0]);\n\n  Function op;\n  switch (arguments[1]) {\n    case '+':\n      op = add;\n      break;\n    case '-':\n      op = sub;\n      break;\n    case '*':\n      op = mul;\n      break;\n    case '/':\n      op = div;\n      break;\n    default:\n      print('Invalid operator!\\n');\n      printUsage();\n      exit(1);\n  }\n\n  int res = op(a, b);\n  print('=\u003e $res');\n}\n```\n\n**lib/calc.dart**\n```dart\nint add(int a, int b) =\u003e a + b;\n\nint sub(int a, int b) =\u003e a - b;\n\nint mul(int a, int b) =\u003e a * b;\n\nint div(int a, int b) =\u003e a ~/ b;\n```\n\nExecute it:\n\n```bash\ndscript math.dart 20 + 5\n```\n\n[![asciicast](https://asciinema.org/a/153074.png?size=small)](https://asciinema.org/a/153074)\n\n## Shebang\n\nShebangs can be used to execute a Dart script directly.\n\n**say_hello.dart**\n```dart\n#! /usr/bin/env dscript\n\nmain() {\n  print('Hello!');\n}\n\n``` \n\nMake it executable:\n```bash\nchmod ug+x say_hello.dart\n```\n\nExecute it:\n```bash\n./say_hello.dart\n```\n\nPut it in system `PATH` and use it like any other shell script!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesktop-dart%2Fdscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesktop-dart%2Fdscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesktop-dart%2Fdscript/lists"}