# p
P makes it easier to jump between projects and get work done.
It gathers up all of the available commands/scripts in a repo,
and aliases them to `p <name>`.
**P is not a project requirement or dependency -- it is a personal
tool.** Nothing in your project should depend on p, but rather conform
to p-friendly standards which are usable with or without p itself.
This means that if you use p,
you get the best experience possible.
And for the contributors who don't use p,
at least they get a well-documented and well-maintained developer experience.
If you *personally* start using it,
you'll probably find that `p` is the first thing you run after `cd <project>` to get your bearings and start doing work.
[But... why?](#why)
## Install or update
Don't add it to a project. Add it to your machine, system-wide or user-wide.
```sh
# System-wide or user-wide, not per project
$ pip3 install -U p
```
## What it looks like
```text
$ cd project
$ p
Usage: p [OPTIONS] COMMAND [ARGS]...
Options:
--version
--help Show this message and exit.
Commands:
compile-assets Using: npm run compile-assets
install Using: ./scripts/install
load-fixtures Using: ./scripts/load-fixtures
pre-commit Using: ./scripts/pre-commit
test Using: ./scripts/test
```
## Supported tools and workflows
Note that p really only supports stuff that we use at [Dropseed](https://www.dropseed.dev/).
**So this list is intentionally short.**
If you use p day-to-day and would like to see support for something not listed here,
[just let us know](https://github.com/dropseed/p/issues)!
### Executable scripts
P will automatically find executable scripts in `./scripts` or `./bin`.
They should have no extension (don't need ".sh") and should be executable (`chmod +x ./scripts/thing`).
The filename will be added as a command so that they can simply be run by doing `p {script-name}`.
For example, this structure:
```text
$ tree scripts/
scripts/
├── compile-assets
├── load-fixtures
├── pre-commit
├── setup
├── start-postgres
├── test
└── work
```
Will result in:
```text
$ p
Usage: p [OPTIONS] COMMAND [ARGS]...
Options:
--version
--help Show this message and exit.
Commands:
compile-assets Using: ./scripts/compile-assets
load-fixtures Using: ./scripts/load-fixtures
pre-commit Using: ./scripts/pre-commit
setup Using: ./scripts/setup
start-postgres Using: ./scripts/start-postgres
test Using: ./scripts/test
work Using: ./scripts/work
```
### Makefile
If there is a `Makefile` in your project,
p will automatically parse `.PHONY` and make those commands available via p.
So if you have `make test`,
it will also be available to p users via `p test`.
### package.json scripts
Entries in your `package.json` "scripts" will automatically be mapped to p commands.
For example:
```js
{
"scripts": {
"start": "react-scripts start"
}
}
```
Would result in:
```text
Usage: p [OPTIONS] COMMAND [ARGS]...
Options:
--version
--help Show this message and exit.
Commands:
start Using: npm run start
```
## Git hooks
P also provides automatic installation of [git hooks](#using-git-hooks).
For example, if you have a command named `pre-commit`, running `p
install` or `p {git-hook-name}` will prompt you to install
it into your local `.githooks` for the repo.
Then when you run `git commit`,
your `p pre-commit` will be run automatically.
An example of a `pre-commit` script:
```sh
#!/bin/sh -e
black pullapprove --check --exclude migrations
```
## Grouping (advanced)
To make the p help more user friendly you can group and hide commands from the top-level.
This works automatically by using a `:` in your command name.
For example, if you have commands like `db:load` and `db:reset`, you'll get a `db` group.
You can run `p db` to see the subcommands in db, and run `p db load` to run a subcommand.
```text
$ p
Usage: p [OPTIONS] COMMAND [ARGS]...
Options:
--version
--help Show this message and exit.
Commands:
db
$ p db load
```
(You can also invoke the grouped commands directly as `p db:load`.)
---
## Why
### Context switching sucks
It can often take several minutes just to figure out how to *start* working on
something.
Every project is different, but damn near every project comes with a set of
development commands or scripts to run common actions. And if it doesn’t, then
it probably should.
Different languages, people, and tools accomplish this in different ways. Some
projects use the good ol’ `Makefile`, while others use `package.json` “scripts”,
bash scripts, `rake`, `fabric`, and so on and so on…
P was built to make it easier to jump between projects,
and to save some keystrokes in the meantime.
### Improving developer experience
Ideally, p will “just work”.
But if not,
it is often in your project’s best interest to design a developer experience that *would* work if someone were using p.
That is – script out some of the most commonly used actions for your project (`install`, `test`, `deploy`, etc.),
and put them in a uniform place where contributors can easily figure out how to use them.
Now even the people who don't use p at least have a shot at getting up and running on their own.
### The search for a universal experience
For a long time I've been in search of the perfect development task manager to use on every project.
But that proved to be difficult as the repos got smaller,
more self-contained,
and spread across languages and dependency systems.
Using a Makefile is the closest thing to what I'm looking for.
Most people have `make`.
But there's a lot of things I just can't stand about it
(it's just ugly, and I can't help but think that it feels like some kind of *hack*).
I've settled on the idea of using a "scripts" folder with one-off files for each task.
Usually just bash scripts,
but can easily be a small Python script or something else.
These work basically everywhere,
and it's not hard to tell someone to do `./scripts/test`.
But even the "scripts" pattern doesn't make sense *on every project*.
Some frameworks/projects already come with a solution,
like pre-existing `package.json` "scripts".
Do we really want to create make `scripts/test` that just runs `npm run test`?
Seems dumb.
"I guess we'll use npm scripts on this project..."
So, every project inevitably ends up being a little bit different.
But for those of us that have to constantly jump around between those projects,
p smooths out the rough edges in our day-to-day,
and enables us to make per-project decisions about the developer experience
(and reminds us to even be thinking about that in the first place).
### Bonus: git hooks
Git hooks can be a super useful,
but confusing process to use.
The [gist](https://www.atlassian.com/git/tutorials/git-hooks#local-hooks) is that they generally aren't shared or set up for each user of a project automatically.
There are some tools like [pre-commit](https://pre-commit.com/) or [husky](https://github.com/typicode/husky) that really go the extra mile in creating a system for git hooks,
but a lot of our projects don't really warrant that and,
again,
it felt strange to now have a project dependency in that process...
Do we install that thing per-project even if the project doesn't use that language otherwise?
If we install it on our machines outside the project,
is that now a requirement that can't be required?
Is it even possible to run the hook/linter/formatter without that tool?
Anyway, p embraces git's (implied) attitude about hooks: they're optional.
If a user has p,
then we'll take an extra step to install the git hook for them and put things in place.
It's a nice-to-have.
If you don't have p, then at least you can still run your linters/formatters manually if you want (i.e. `npm run pre-commit`).
And if you need to *require* that those checks are run,
no matter who (or what) commits to the project?
Then set them up in CI.
You don't need anything special to do this --
just run your script/command as a step like a non-p user would.
It's not fancy,
and it works for us.
## Inspired by
- [Dropseed’s](https://github.com/dropseed) project-cli (private)
- [Flint Hills Design’s](https://github.com/flinthillsdesign) fhd-cli (private)
- [https://github.com/github/scripts-to-rule-them-all](https://github.com/github/scripts-to-rule-them-all)
- [https://github.com/bkeepers/strappydoo](https://github.com/bkeepers/strappydoo)
- having too many projects
Raw data
{
"_id": null,
"home_page": "https://www.dropseed.dev/p",
"name": "p",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "cli, alias, commands, scripts, bin",
"author": "Dave Gaeddert",
"author_email": "dave.gaeddert@dropseed.dev",
"download_url": "https://files.pythonhosted.org/packages/b4/05/f5f855d1efac6f55320d63f51c1dd252cfbd0c758b42b0596cff0e63e184/p-1.5.0.tar.gz",
"platform": null,
"description": "# p\n\nP makes it easier to jump between projects and get work done.\nIt gathers up all of the available commands/scripts in a repo,\nand aliases them to `p <name>`.\n\n**P is not a project requirement or dependency -- it is a personal\ntool.** Nothing in your project should depend on p, but rather conform\nto p-friendly standards which are usable with or without p itself.\nThis means that if you use p,\nyou get the best experience possible.\nAnd for the contributors who don't use p,\nat least they get a well-documented and well-maintained developer experience.\n\nIf you *personally* start using it,\nyou'll probably find that `p` is the first thing you run after `cd <project>` to get your bearings and start doing work.\n\n[But... why?](#why)\n\n## Install or update\n\nDon't add it to a project. Add it to your machine, system-wide or user-wide.\n\n```sh\n# System-wide or user-wide, not per project\n$ pip3 install -U p\n```\n\n## What it looks like\n\n```text\n$ cd project\n$ p\n Usage: p [OPTIONS] COMMAND [ARGS]...\n\n Options:\n --version\n --help Show this message and exit.\n\n Commands:\n compile-assets Using: npm run compile-assets\n install Using: ./scripts/install\n load-fixtures Using: ./scripts/load-fixtures\n pre-commit Using: ./scripts/pre-commit\n test Using: ./scripts/test\n```\n\n## Supported tools and workflows\n\nNote that p really only supports stuff that we use at [Dropseed](https://www.dropseed.dev/).\n**So this list is intentionally short.**\nIf you use p day-to-day and would like to see support for something not listed here,\n[just let us know](https://github.com/dropseed/p/issues)!\n\n### Executable scripts\n\nP will automatically find executable scripts in `./scripts` or `./bin`.\n\nThey should have no extension (don't need \".sh\") and should be executable (`chmod +x ./scripts/thing`).\n\nThe filename will be added as a command so that they can simply be run by doing `p {script-name}`.\n\n\nFor example, this structure:\n\n```text\n$ tree scripts/\nscripts/\n\u251c\u2500\u2500 compile-assets\n\u251c\u2500\u2500 load-fixtures\n\u251c\u2500\u2500 pre-commit\n\u251c\u2500\u2500 setup\n\u251c\u2500\u2500 start-postgres\n\u251c\u2500\u2500 test\n\u2514\u2500\u2500 work\n```\n\nWill result in:\n\n```text\n$ p\n Usage: p [OPTIONS] COMMAND [ARGS]...\n\n Options:\n --version\n --help Show this message and exit.\n\n Commands:\n compile-assets Using: ./scripts/compile-assets\n load-fixtures Using: ./scripts/load-fixtures\n pre-commit Using: ./scripts/pre-commit\n setup Using: ./scripts/setup\n start-postgres Using: ./scripts/start-postgres\n test Using: ./scripts/test\n work Using: ./scripts/work\n```\n\n### Makefile\n\nIf there is a `Makefile` in your project,\np will automatically parse `.PHONY` and make those commands available via p.\nSo if you have `make test`,\nit will also be available to p users via `p test`.\n\n### package.json scripts\n\nEntries in your `package.json` \"scripts\" will automatically be mapped to p commands.\n\nFor example:\n\n```js\n{\n \"scripts\": {\n \"start\": \"react-scripts start\"\n }\n}\n```\n\nWould result in:\n\n```text\nUsage: p [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --version\n --help Show this message and exit.\n\nCommands:\n start Using: npm run start\n```\n\n## Git hooks\n\nP also provides automatic installation of [git hooks](#using-git-hooks).\n\nFor example, if you have a command named `pre-commit`, running `p\ninstall` or `p {git-hook-name}` will prompt you to install\nit into your local `.githooks` for the repo.\n\nThen when you run `git commit`,\nyour `p pre-commit` will be run automatically.\n\nAn example of a `pre-commit` script:\n```sh\n#!/bin/sh -e\nblack pullapprove --check --exclude migrations\n```\n\n## Grouping (advanced)\n\nTo make the p help more user friendly you can group and hide commands from the top-level.\nThis works automatically by using a `:` in your command name.\n\nFor example, if you have commands like `db:load` and `db:reset`, you'll get a `db` group.\nYou can run `p db` to see the subcommands in db, and run `p db load` to run a subcommand.\n\n```text\n$ p\n Usage: p [OPTIONS] COMMAND [ARGS]...\n\n Options:\n --version\n --help Show this message and exit.\n\n Commands:\n db\n\n$ p db load\n```\n\n(You can also invoke the grouped commands directly as `p db:load`.)\n\n---\n\n## Why\n\n### Context switching sucks\n\nIt can often take several minutes just to figure out how to *start* working on\nsomething.\n\nEvery project is different, but damn near every project comes with a set of\ndevelopment commands or scripts to run common actions. And if it doesn\u2019t, then\nit probably should.\nDifferent languages, people, and tools accomplish this in different ways. Some\nprojects use the good ol\u2019 `Makefile`, while others use `package.json` \u201cscripts\u201d,\nbash scripts, `rake`, `fabric`, and so on and so on\u2026\n\nP was built to make it easier to jump between projects,\nand to save some keystrokes in the meantime.\n\n### Improving developer experience\n\nIdeally, p will \u201cjust work\u201d.\nBut if not,\nit is often in your project\u2019s best interest to design a developer experience that *would* work if someone were using p.\nThat is \u2013 script out some of the most commonly used actions for your project (`install`, `test`, `deploy`, etc.),\nand put them in a uniform place where contributors can easily figure out how to use them.\nNow even the people who don't use p at least have a shot at getting up and running on their own.\n\n### The search for a universal experience\n\nFor a long time I've been in search of the perfect development task manager to use on every project.\nBut that proved to be difficult as the repos got smaller,\nmore self-contained,\nand spread across languages and dependency systems.\n\nUsing a Makefile is the closest thing to what I'm looking for.\nMost people have `make`.\nBut there's a lot of things I just can't stand about it\n(it's just ugly, and I can't help but think that it feels like some kind of *hack*).\n\nI've settled on the idea of using a \"scripts\" folder with one-off files for each task.\nUsually just bash scripts,\nbut can easily be a small Python script or something else.\nThese work basically everywhere,\nand it's not hard to tell someone to do `./scripts/test`.\n\nBut even the \"scripts\" pattern doesn't make sense *on every project*.\nSome frameworks/projects already come with a solution,\nlike pre-existing `package.json` \"scripts\".\nDo we really want to create make `scripts/test` that just runs `npm run test`?\nSeems dumb.\n\"I guess we'll use npm scripts on this project...\"\n\nSo, every project inevitably ends up being a little bit different.\nBut for those of us that have to constantly jump around between those projects,\np smooths out the rough edges in our day-to-day,\nand enables us to make per-project decisions about the developer experience\n(and reminds us to even be thinking about that in the first place).\n\n### Bonus: git hooks\n\nGit hooks can be a super useful,\nbut confusing process to use.\nThe [gist](https://www.atlassian.com/git/tutorials/git-hooks#local-hooks) is that they generally aren't shared or set up for each user of a project automatically.\nThere are some tools like [pre-commit](https://pre-commit.com/) or [husky](https://github.com/typicode/husky) that really go the extra mile in creating a system for git hooks,\nbut a lot of our projects don't really warrant that and,\nagain,\nit felt strange to now have a project dependency in that process...\nDo we install that thing per-project even if the project doesn't use that language otherwise?\nIf we install it on our machines outside the project,\nis that now a requirement that can't be required?\nIs it even possible to run the hook/linter/formatter without that tool?\n\nAnyway, p embraces git's (implied) attitude about hooks: they're optional.\n\nIf a user has p,\nthen we'll take an extra step to install the git hook for them and put things in place.\nIt's a nice-to-have.\n\nIf you don't have p, then at least you can still run your linters/formatters manually if you want (i.e. `npm run pre-commit`).\n\nAnd if you need to *require* that those checks are run,\nno matter who (or what) commits to the project?\nThen set them up in CI.\nYou don't need anything special to do this --\njust run your script/command as a step like a non-p user would.\n\nIt's not fancy,\nand it works for us.\n\n## Inspired by\n- [Dropseed\u2019s](https://github.com/dropseed) project-cli (private)\n- [Flint Hills Design\u2019s](https://github.com/flinthillsdesign) fhd-cli (private)\n- [https://github.com/github/scripts-to-rule-them-all](https://github.com/github/scripts-to-rule-them-all)\n- [https://github.com/bkeepers/strappydoo](https://github.com/bkeepers/strappydoo)\n- having too many projects\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Aliases any available project commands or scripts to `p <name>`.",
"version": "1.5.0",
"project_urls": {
"Documentation": "https://www.dropseed.dev/p",
"Homepage": "https://www.dropseed.dev/p",
"Repository": "https://github.com/dropseed/p"
},
"split_keywords": [
"cli",
" alias",
" commands",
" scripts",
" bin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b6c853c39a231c2e511f3624dba5bc75e8bb7ac55165895968c96ef7afeb8cfc",
"md5": "4692f6a93ba8434db9d409ccaa5d4cd6",
"sha256": "28c975699d73f7ea1f74efeaffac4b64af06d0847b8e7619ddf6e59078ea10c0"
},
"downloads": -1,
"filename": "p-1.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4692f6a93ba8434db9d409ccaa5d4cd6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 10582,
"upload_time": "2024-09-20T20:22:55",
"upload_time_iso_8601": "2024-09-20T20:22:55.675218Z",
"url": "https://files.pythonhosted.org/packages/b6/c8/53c39a231c2e511f3624dba5bc75e8bb7ac55165895968c96ef7afeb8cfc/p-1.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b405f5f855d1efac6f55320d63f51c1dd252cfbd0c758b42b0596cff0e63e184",
"md5": "632beb29d6239a87303d8113d5e80aaa",
"sha256": "5a6466b39013f8bbfb7054c950aee87f0a6ee72ac366f8f1ea030200c0c5d332"
},
"downloads": -1,
"filename": "p-1.5.0.tar.gz",
"has_sig": false,
"md5_digest": "632beb29d6239a87303d8113d5e80aaa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 11413,
"upload_time": "2024-09-20T20:22:56",
"upload_time_iso_8601": "2024-09-20T20:22:56.924447Z",
"url": "https://files.pythonhosted.org/packages/b4/05/f5f855d1efac6f55320d63f51c1dd252cfbd0c758b42b0596cff0e63e184/p-1.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-20 20:22:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dropseed",
"github_project": "p",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "p"
}