{"id":14156090,"url":"https://github.com/xshoji/bash-script-starter","last_synced_at":"2026-02-06T01:49:46.773Z","repository":{"id":98653682,"uuid":"142427826","full_name":"xshoji/bash-script-starter","owner":"xshoji","description":"ScriptStarter provides a means to generate a pretty template of bash script.","archived":false,"fork":false,"pushed_at":"2023-01-29T06:56:32.000Z","size":93,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-08-17T08:06:32.106Z","etag":null,"topics":["autogenerated","bash-script","shell-script","template"],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/xshoji.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-26T10:48:00.000Z","updated_at":"2024-05-04T04:15:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"c780386d-3f1f-4a84-b87a-704bdaa5524c","html_url":"https://github.com/xshoji/bash-script-starter","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/xshoji%2Fbash-script-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshoji%2Fbash-script-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshoji%2Fbash-script-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshoji%2Fbash-script-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xshoji","download_url":"https://codeload.github.com/xshoji/bash-script-starter/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228829055,"owners_count":17978143,"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":["autogenerated","bash-script","shell-script","template"],"created_at":"2024-08-17T08:05:12.609Z","updated_at":"2026-02-06T01:49:46.715Z","avatar_url":"https://github.com/xshoji.png","language":"Shell","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"# bash-script-starter\n\nScriptStarter provides a means to generate a nice template of a bash script.\n\n\u003cimg src=\"https://i.imgur.com/5M0Udbv.gif\" width=\"80%\" height=\"80%\" style=\"border:0;box-shadow:0 0 0 0; \" alt=\"Demo\"\u003e\n\n## Usage\n\nSet ScriptStarter url.\n\n```\nbash-4.2# STARTER_URL=https://raw.githubusercontent.com/xshoji/bash-script-starter/master/ScriptStarter.sh\n```\n\nDisplay usage.\n\n```\nbash-4.2# ./ScriptStarter.sh -h\n\n ScriptStarter\n------------------ author: xshoji\n\nThis script generates a template of bash script tool.\n\nUsage:\n  ./ScriptStarter.sh --naming scriptName [ --author author --description Description --description ... --required paramName,sample,description --required ... --optional paramName,sample,description,defaultValue(omittable) --optional ... --flag flagName,description --flag ... --env variableName,sample --env ... --short  --keep-starter-parameters --protect-arguments ]\n\nRequired:\n  -n, --naming scriptName : Script name.\n\nOptional:\n  -a, --author author                                                 : Script author.\n  -d, --description Description                                       : Description of this script. [ example: --description \"ScriptStarter's description here.\" ]\n  -r, --required paramName,sample,description                         : Required parameter setting. [ example: --required id,1001,\"Primary id here.\" ]\n  -o, --optional paramName,sample,description,defaultValue(omittable) : Optional parameter setting. [ example: --option name,xshoji,\"User name here.\",defaultUser ]\n  -f, --flag flagName,description                                     : Optional flag setting. [ example: --flag dryRun,\"Dry run mode.\" ]\n  -e, --env variableName,sample                                       : Required environment variable setting. [ example: --env API_HOST,example.com ]\n  -s, --short                   : Enable short parameter. [ example: --short ]\n  -k, --keep-starter-parameters : Keep parameter details of bash-script-starter in the generated scprit. [ example: --keep-starter-parameters ]\n  -p, --protect-arguments       : Declare argument variables as readonly. [ example: --protect-arguments ]\n\nHelper options:\n  --help, --debug\n\nbash-4.2#\n```\n\nA sample of generated script [here](sample/GeneratedScriptSample.sh).\n\n## Generate script\n\n### Plain\n\nPlain script no needs parameter.\n\n`-h` and `--debug` options are supported as default.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji \u003e MyScript\nbash-4.2# ./MyScript -h\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript\n\nHelper options:\n  --help, --debug\n\nbash-4.2# ./MyScript\nbash-4.2#\n```\n\n### Required parameters\n\nRequired parameters are validated.\n\nMissing parameters are displayed as `[!]`.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji -r id,1001 -r name,xshoji \u003e MyScript\nbash-4.2# ./MyScript\n[!] --id is required.\n[!] --name is required.\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript --id 1001 --name xshoji\n\nRequired:\n  --id 1001     : \"1001\" means id.\n  --name xshoji : \"xshoji\" means name.\n\nHelper options:\n  --help, --debug\n\nbash-4.2#\n```\n\n### Optional parameters\n\nOptional parameters will be not validated.\n\nThese optional parameters are initialised with a default value.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji -o id,1001 -o name,xshoji,\"A user name.\",\"guest\" \u003e MyScript\nbash-4.2# ./MyScript -h\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript [ --id 1001 --name xshoji ]\n\nOptional:\n  --id 1001     : \"1001\" means id.\n  --name xshoji : A user name. [ default: guest ]\n\nHelper options:\n  --help, --debug\n\nbash-4.2# ./MyScript\n\n[ Optional parameters ]\nid: 1001\nname: guest\n\nbash-4.2# ./MyScript --name myname\n\n[ Optional parameters ]\nid:\nname: myname\n\nbash-4.2#\n```\n\n### Flags\n\nFlags will be not validated.\n\nThese flags are set to \"true\" string when enabled  (default: empty string).\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji -f strict -f dryRun \u003e MyScript\nbash-4.2# ./MyScript -h\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript [ --strict --dryRun ]\n\nOptional:\n  --strict : Enable strict flag.\n  --dryRun : Enable dryRun flag.\n\nHelper options:\n  --help, --debug\n\nbash-4.2# ./MyScript --strict\n\n[ Optional parameters ]\nstrict: true\ndryRun: false\n\nbash-4.2# ./MyScript --dryRun\n\n[ Optional parameters ]\nstrict: false\ndryRun: true\n\nbash-4.2#\n```\n\n### Environment variables\n\nYou can check which environment variables be should be exported.\n\nMissing environment variables are displayed as `[!]`.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji -e ENV_VAR_A,1001 -e ENV_VAR_B,xshoji \u003e MyScript\nbash-4.2# ./MyScript\n[!] export ENV_VAR_A=1001 is required.\n[!] export ENV_VAR_B=xshoji is required.\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript\n\nEnvironment variables:\n  export ENV_VAR_A=1001\n  export ENV_VAR_B=xshoji\n\nHelper options:\n  --help, --debug\n\nbash-4.2# export ENV_VAR_A=1001; export ENV_VAR_B=xshoji\nbash-4.2# ./MyScript\n\n[ Environment variables ]\nENV_VAR_A: 1001\nENV_VAR_B: xshoji\n```\n\n### Support short name parameters\n\nYou can specify any parameters as a short name parameter.\n\nThe `-s, --short` option enables short parameters.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -a xshoji -r id,1001 -o name,xshoji -f dryRun -s \u003e MyScript\nbash-4.2# ./MyScript\n[!] --id is required.\n\n MyScript\n------------- author: xshoji\n\nThis is MyScript.\n\nUsage:\n  ./MyScript --id 1001 [ --name xshoji --dryRun ]\n\nRequired:\n  -i, --id 1001 : \"1001\" means id.\n\nOptional:\n  -n, --name xshoji : \"xshoji\" means name.\n  -d, --dryRun : Enable dryRun flag.\n\nHelper options:\n  --help, --debug\n\nbash-4.2# ./MyScript -i 1001 -n myname -d\n\n[ Required parameters ]\nid: 1001\n\n[ Optional parameters ]\nname: myname\ndryRun: true\n```\n\n### Protect arguments\n\n`-p, --protect-arguments` option generates readonly declaring.\n\n```\nbash-4.2# curl -sf ${STARTER_URL} |bash -s - -n MyScript -r id,1001 -o name,xshoji -s -p \u003e MyScript\nbash-4.2# cat MyScript\n...\n# To readonly variables\nreadonly ID\nreadonly NAME\n...\n```\n\n## How to use the generated script?\n\nYour script should be writen following \"Main\".\n\nIf you would like to alter script parameters, you re-generate a script template by ScriptStarter.\nThen, lines from top to \"Main\" on generated template only have to be copied and pasted to your script.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxshoji%2Fbash-script-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxshoji%2Fbash-script-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxshoji%2Fbash-script-starter/lists"}