{"id":24629502,"url":"https://github.com/sharpjs/subatomix.powershell.taskhost","last_synced_at":"2025-03-20T04:35:48.681Z","repository":{"id":68403157,"uuid":"412828566","full_name":"sharpjs/Subatomix.PowerShell.TaskHost","owner":"sharpjs","description":"A PowerShell PSHost wrapper to improve the clarity of output from parallel tasks","archived":false,"fork":false,"pushed_at":"2023-12-03T17:59:54.000Z","size":548,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-27T07:42:13.643Z","etag":null,"topics":["parallel","powershell"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2021-10-02T15:02:14.000Z","updated_at":"2022-05-09T01:40:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"470e8990-2f59-4782-aaf4-1f7da9b4677f","html_url":"https://github.com/sharpjs/Subatomix.PowerShell.TaskHost","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.PowerShell.TaskHost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.PowerShell.TaskHost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.PowerShell.TaskHost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharpjs%2FSubatomix.PowerShell.TaskHost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharpjs","download_url":"https://codeload.github.com/sharpjs/Subatomix.PowerShell.TaskHost/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554042,"owners_count":20471172,"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":["parallel","powershell"],"created_at":"2025-01-25T06:13:07.788Z","updated_at":"2025-03-20T04:35:48.665Z","avatar_url":"https://github.com/sharpjs.png","language":"C#","readme":"## About\n\nThe **TaskHost** PowerShell module and **Subatomix.PowerShell.TaskHost** NuGet\npackage provide a thread-safe PowerShell\n[`PSHost`](https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshost)\nwrapper to improve the clarity of output from long-running, possibly parallel\ntasks.\n\nTaskHost adds a header to each line of output, reporting the elapsed time and\nwhich task produced the output.  Line header components are optional and use\ncolor where supported.\n \n![Example output](https://raw.githubusercontent.com/sharpjs/Subatomix.PowerShell.TaskHost/main/misc/example.png)\n\n## Status\n\n[![Build](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/workflows/Build/badge.svg)](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/actions)\n[![Build](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/actions)\n[![PSGallery](https://img.shields.io/powershellgallery/v/TaskHost.svg)](https://www.powershellgallery.com/packages/TaskHost)\n[![PSGallery](https://img.shields.io/powershellgallery/dt/TaskHost.svg)](https://www.powershellgallery.com/packages/TaskHost)\n[![NuGet](https://img.shields.io/nuget/v/Subatomix.PowerShell.TaskHost.svg)](https://www.nuget.org/packages/Subatomix.PowerShell.TaskHost)\n[![NuGet](https://img.shields.io/nuget/dt/Subatomix.PowerShell.TaskHost.svg)](https://www.nuget.org/packages/Subatomix.PowerShell.TaskHost)\n\n- **Tested:**      100% coverage by automated tests.\n- **Documented:**  IntelliSense on everything.  Quick-start guide below.\n\n## Installation\n\n⚠ **These instructions are for version 2.0 pre-releases.**  For version 1.0, see\n[the prior version of these instructions](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/blob/release/1.0.0/README.md).\n\nFrom PowerShell 7 or later, install [the TaskHost module](https://www.powershellgallery.com/packages/TaskHost):\n\n```ps1\nInstall-Module TaskHost -AllowPrerelease\n```\n\nUpdate or uninstall the module with `Update-Module` or `Uninstall-Module`,\nrespectively.\n\nDevelopers wanting to implement similar features in their own software can install\n[the Subatomix.PowerShell.TaskHost NuGet package](https://www.nuget.org/packages/Subatomix.PowerShell.TaskHost)\nto get the building blocks of the TaskHost module.\n\n## Usage\n\n⚠ **These instructions are for version 2.0 pre-releases.**  For version 1.0, see\n[the prior version of these instructions](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/blob/release/1.0.0/README.md).\n\n### The Basics\n\nStart with a `Use-TaskHost` command.\n\n```ps1\nUse-TaskHost {\n}\n```\n\nOptionally, add `-WithElapsed` to enable the elapsed-time header.\n\n```ps1\nUse-TaskHost -WithElapsed {\n}\n```\n\nFor each task, add an `Invoke-Task` command.\n\n```ps1\nUse-TaskHost -WithElapsed  {\n\n    Invoke-Task \"Step 1\" {\n        Write-Host \"Example output from a task\"\n    }\n\n    Invoke-Task \"Step 2\" {\n        Write-Host \"Example output from another task\"\n    }\n\n}\n```\n\nOutput:\n\n```\n[+00:00:00] [Step 1]: Example output from a task\n[+00:00:00] [Step 2]: Example output from another task\n```\n\nA task is a chunk of code whose output should be distinguishable from that of\nother tasks and non-task code.  Beyond that, what constitutes a task is\nentirely at the discretion of the user of this module.  There is no restriction\non the number of or size of tasks or on what can appear in a task's script\nblock.\n\nTasks are nestable.\n\n```ps1\nUse-TaskHost -WithElapsed  {\n    Invoke-Task \"Step 3\" {\n\n        Invoke-Task \"Part 1\" {\n            Write-Host \"Example output from a nested task\"\n        }\n\n    }\n}\n```\n\nOutput:\n\n```\n[+00:00:00] [Step 3|Part 1]: Example output from a nested task\n```\n\n### Advanced Usage\n\nThe PowerShell `ForEach-Object -Parallel` command complicates the preceding\nexample. See\n[this script](https://github.com/sharpjs/Subatomix.PowerShell.TaskHost/blob/main/Subatomix.PowerShell.TaskHost.Module/Test-TaskHost.ps1)\nfor a working example with detailed explanation.\n\nInformation about the currently executing task is available via the following\nexpression, which returns null if there is no such task:\n\n```ps1\n[Subatomix.PowerShell.TaskHost.TaskInfo]::Current\n```\n\nThe `TaskInfo` object provides a few useful properties:\n\n- `Id`       – Unique integer identifier for the task.\n- `Name`     – Name of the task.  Writable.\n- `FullName` – `Name` prefixed with the `FullName` of the task's parent, if any.\n- `Parent`   – The task in which the current task is nested, if any.\n\nThe `FullName` property determines the text that TaskHost prepends to each\noutput line.  To change the text, set the `Name` property of the task or of its\nancestors.\n\n```ps1\n[Subatomix.PowerShell.TaskHost.TaskInfo]::Current.Name = \"New name\"\n```\n\nTo remove the line header, set the property to an empty string.\n\n```ps1\n[Subatomix.PowerShell.TaskHost.TaskInfo]::Current.Name = \"\"\n```\n\n\u003c!--\n  Copyright 2023 Subatomix Research Inc.\n  SPDX-License-Identifier: ISC\n--\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fsubatomix.powershell.taskhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharpjs%2Fsubatomix.powershell.taskhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharpjs%2Fsubatomix.powershell.taskhost/lists"}