{"id":22870199,"url":"https://github.com/berquerant/linep","last_synced_at":"2025-05-07T15:24:21.840Z","repository":{"id":265068824,"uuid":"895035851","full_name":"berquerant/linep","owner":"berquerant","description":"process lines by one liner","archived":false,"fork":false,"pushed_at":"2025-03-24T12:38:20.000Z","size":189,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T11:30:31.519Z","etag":null,"topics":["go"],"latest_commit_sha":null,"homepage":"","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/berquerant.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":"2024-11-27T12:53:16.000Z","updated_at":"2025-03-24T12:38:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"5ca5cecc-0cc9-43ee-b181-f43a719dffff","html_url":"https://github.com/berquerant/linep","commit_stats":null,"previous_names":["berquerant/linep"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Flinep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Flinep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Flinep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berquerant%2Flinep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berquerant","download_url":"https://codeload.github.com/berquerant/linep/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252903661,"owners_count":21822484,"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":["go"],"created_at":"2024-12-13T13:14:06.816Z","updated_at":"2025-05-07T15:24:21.814Z","avatar_url":"https://github.com/berquerant.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# linep\n\n``` shell\n❯ linep\nlinep -- process lines by one liner\n\nUsage:\nlinep TEMPLATE MAP [FLAGS]\nlinep TEMPLATE INIT MAP [FLAGS]\nlinep TEMPLATE INIT MAP REDUCE [FLAGS]\n\nTEMPLATE: go, py, python, pipenv, rs, rust, nil, null, empty\n\nRequirements of templates:\ngo: go\npython, py: python\npipenv: pipenv, pyenv\nrust, rs: cargo\n\nExamples:\n\u003e seq 3 | linep go 'fmt.Println(x+\"0\")' -q\n10\n20\n30\n\n\u003e seq 10 | linep rust 'let n:i32=x.parse().unwrap();if n%2==0{println!(\"{}\",n)}' -q\n2\n4\n6\n8\n10\n\n\u003e seq 4 | linep pipenv 'acc=[]' 'acc.append(int(x));print(math.prod(acc))' 'print(sum(acc))' --import 'math' -q\n1\n2\n6\n24\n10\n\n# without pipenv\n\u003e seq 3 | linep pipenv 'print(x+\"0\")' --exec 'python @MAIN' --init 'sleep 0'\n10\n20\n30\n# is almost equivalent to\n\u003e seq 3 | linep py 'print(x+\"0\")'\n\n# indent MAP (python)\n\u003e linep py 'r={}' 'x=x.split(\".\")[-1]\nif x in r:\n  r[x]+=1\nelse:\n  r[x]=1' 'for k, v in r.items():\n  print(f\"{k}\\t{v}\")' --dry\nimport sys\nimport signal\nsignal.signal(signal.SIGPIPE, signal.SIG_DFL)\nr={}\ntry:\n  for x in sys.stdin:\n    x = x.rstrip()\n    x=x.split(\".\")[-1]\n    if x in r:\n      r[x]+=1\n    else:\n      r[x]=1\nexcept BrokenPipeError:\n  pass\nfor k, v in r.items():\n  print(f\"{k}\\t{v}\")\n\nTemplates:\nTEMPLATE argument can be a template filename.\nempty (nil, null) template is for overriding.\nA template file format is:\n\n# template name, required.\nname: sample\n# generated script name, required.\nmain: main.go\n# aliases of name.\n# also used by TEMPLATE argument.\nalias:\n  - smpl\n# template of script body (main.go, main.py, ...).\n# executed by https://pkg.go.dev/text/template with https://masterminds.github.io/sprig/\n# available fields:\n#   Init   : INIT argument (string)\n#   Map    : MAP argument (string)\n#   Reduce : REDUCE argument (string)\n#   Import : --import argument (slice of string)\nscript: |\n  ...\n# init script command.\n# initialize a directory of generated script like 'go mod init'.\n# macros are replaced with a reference of an environment variable.\n# available macros:\n#   @MAIN     : main of this template\n#   @WORK_DIR : --workDir argument\n#   @EXEC_PWD : current directory of linep execution\n#   @SRC_DIR  : directory of the generated script\ninit: |\n  ...\n# execute script command.\n# execute generated script like 'go run @MAIN'.\n# macros are available.\nexec: |\n  ...\n\n# show template\n\u003e linep go --displayTemplate\n\nEnvironment variables:\nYou can use the flag name with the hyphen removed and converted to uppercase as an environment variable.\nIf both the corresponding flag and the environment variable are specified at the same time, the flag takes precedence.\n\nFlags:\n      --debug             enable debug logs\n      --displayTemplate   do not run; display template\n      --dry               do not run; display generated script\n      --exec string       override exec script\n  -i, --import string     additional libraries; separated by '|'\n      --init string       override init script\n      --keep              keep generated script directory\n      --main string       override main script name\n  -q, --quiet             quiet stderr logs\n      --script string     override script\n      --sh string         execute shell command; separated by ';' (default \"sh\")\n  -w, --workDir string    working directory; default: $HOME/.linep\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Flinep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberquerant%2Flinep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberquerant%2Flinep/lists"}