Git Product home page Git Product logo

pier's People

Contributors

benschza avatar danielrivasmd avatar korrat avatar krive001 avatar lynnesbian avatar niniack avatar plommonsorbet avatar thekodeking avatar tshepang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pier's Issues

Maybe we should create a gihub wiki or a pier-contrib repo?

I think it would be cool if we had some sort of platform where we can share scripts, workflow examples, extensions etc. I always appreciate learning about other people's workflows and it feels appropriate to have something like that considering the tool. It's also a good place to increase the documentation and link to related tools.

  • Here's a very simple fzf menu i made that perhaps would be interesting to add to something like that:
pfz() {
    pier list -q \
        | fzf -m --preview 'pier show {} | bat --color=always' \
        --bind 'ctrl-y:execute(pier show {} | xsel -b)+abort' \
        | xargs -n 1 -I {} pier run {}
}
  • I was considering creating an emacs plugin for pier as way to learn elisp, my idea is implementing a plugin with fuzzy selection, execution, repl / paste to buffer etc. Obviously that would go in a separate repository but things like that would be a good place to link from a wiki.

Some examples of what I mean:

Publish pier as a crate

As someone looking to try out pier, it would be nice if I could just "cargo install" it, and not have to worry about manually needing to keep it updated.

Weird parsing of escaped characters

Hi, I'm trying to add a one-liner with this snippet in it:
sed -r "s/^[0-9.]+\s+//"
However, when it gets parsed, this part of the command transforms to:
sed -r s/^[0-9.]+s+//

Once I replaced \s with [ ], the command parsed correctly. Is this a bug or something I have to work around?

Run command oddities

Was looking into how the commands were being run and noticed that commands with | or ' doesn't work by default and thought I would document it as an issue.

However both | and ' does work if you wrap it in for example bash -c as seen in the config at the bottom.

Perhaps this issue could be solved by wrapping all commands in the default shell from the environment variable $SHELL?

Might also be a good idea when creating new commands through the cli to save them as string literals in the toml config file, it helps avoid a lot of escaping.

Config snippet

[scripts.pass-me]
alias = "pass-me"
command = '''bash -c "echo 'hello'" '''

[scripts.fail-me]
alias = "fail-me"
command = '''echo 'hello' '''


[scripts.fail-me-2]
alias = "fail-me-2"
command = '''echo 1001_hello_1001 | grep -oe "_\\s+_"'''

[scripts.pass-me-2]
alias = "pass-me-2"
command = '''bash -c "echo 1001_hello_1001 | grep -oe "_\\s+_""'''

Run output boiler plate suggestions?

Currently it's a bit hard to pipe the output of pier into anything else as there is a bit of boiler plate in the run output. I've been thinking a bit about how to solve this, some of my ideas are:

  • Remove it completely.
  • Move it to only print on verbose mode.
  • Add an option for a 'quiet-mode'

Personally I think the best option would be to move it to only print in verbose mode, I think it can be nice to see sometimes. But usually you want to be able to do something with the output and having to use a flag every time you want to pipe pier to something else could get a bit annoying.

I'd love to hear your opinion Ben / anyone else :)

Config file generation

Hi, just getting started with the tool, so I may have overlooked something!

From what I understand, we are meant to create our own config file and store the path as an environment variable for pier, right?

Would it be beneficial to have pier automatically generate a config file (and store it in /usr/bin or something) by default? Or is this against the vision/idea in some way?

JSON output of the script struct with the subcommand show

Adding the option to programatically export the pier data would be a nice feature and would make it a lot easier to make 3rd plugins to pier, especially if we're planning on adding more complex features.

Flag short / long name

I think it would be nice to keep it relatively open and use an output flag with a parameter format, which we could expand upon later. e.g.
-o json / --output json
instead of:
-j / --json

Fix duplicate `alias` in configuration.

Currently the config has a duplicate definition of the script alias, would be nice to remove one of them. Will probably require a bit of code shuffling to make work though.

[scripts.this-is-the-alias]
alias = 'this-is-the-alias'
command = '''
#!/bin/sh
echo "Hello $1, my name is $2. -- script $0"
'''

Pass ~~Magic variables~~ to the script

Perhaps pier should pass on some variables to the script with basic pier information?

Some examples:

PIER_ALIAS=<alias>
PIER_COMMAND=pier run <alias> -c /path/to/config
PIER_CONFIG=/path/to/config
PIER_VERSION=0.1.x
PIER_STARTED_UNIX=1583917662
PIER_STARTED_UTC=2020-03-11T09:08:16Z

Allow new scripts to be added from stdin with the add command

This option would make migrating existing shell scripts to pier a lot easier!

Example usage

echo 'for i in {1..10}; do echo $i; done' | pier add -a count_to_ten

Perhaps in the future we could add a json input option as well where you dump the whole script struct into stdin. :)

Allow use of `pier ls` as alias for `list`

I often find myself typing pier ls instead of list - probably because of being used to that with Docker, and the ls CLI tool. It should be fairly easy having two options for listing. Another thought was whether the default when running pier should be to list, as that's quite a common task? Feedback welcome! Maybe I'll take this on, haven't been active in a while.

# Ideas / thoughts about how to implement args.

The args feature has been mocked up for a while and I've had it in the back of my mind how it would be good to implement it, initially I was thinking you could just do some templating but I pretty soon realized that it's a pretty big security flaw as you could then literally inject code before you run it.

Right now I'm leaning towards the best option would be to implement arguments/options as env variables, perhaps via a key/value cli arg with the ability to set defaults for a tag/script in the configt.

I imagine the cli option for setting environment variables to something like -E/--env it could look something like this perhaps:
pier run build_something -E RUST_BACKTRACE:1 -E DB_HOST:127.0.0.1

Pier pager option for subcommands list / run / show

Adding optional pager would be really nice and it's pretty convient to do with the pager crate.

flag long / short name

-p <my pager> --pager <my pager>

Config option

use_pager = true // Sets wheter to page by default

Env variables

PAGER
PIER_PAGER

Suggested pager priority

  1. -p / --pager (cli)
  2. PIER_PAGER (env)
  3. PAGER (env)
  4. PIER_PAGER (env)

links:

docs.rs - pager

Shell completion

Pier is lacking shell completions at the moment for all the cli options, however since pier is using clap / structopt this does not seem relatively easy to do.

To start with perhaps we should limit it to bash / zsh just to keep it simple, however it seems like it's possible to generate powershell / fish completions via clap as well.

I'm not sure how well pier works on windows right now at least, but I'd be curious to know.

Useful links:

docs.rs about the shell generation in clap
structopt example code for generating shell completions

Pier should exit unsuccesully on failed script

Currently pier won't exit unsuccessfully even if the script being run does.

One way to do this would be to check for an unsucessful exit with the Output struct that we get back from the command and if it's unsucessful return an error like ScriptError with pier_err! and then in the main function compare the error returned using the EnumKind proc macro that is applied to the PierError enum.

An example of this type of comparison on errors can be found in these files tests/macros.rs and test/error_handling.rs.

Links:
[https://doc.rust-lang.org/std/process/struct.Output.html](Rust docs - std::process::Output)
[https://docs.rs/enum-kinds/0.4.1/enum_kinds/](docs.rs - enum_kinds)

Multiline command not displaying table correctly when running list

The list command is creating a new table row when dispaying multiline commands, ex:

Alias tags Command
1-test-single-line - echo this is a single line command
2-test-multi-line - echo This
- - echo is
- - echo over
- - echo multiple
- - echo lines
3-test-another-single-line - echo this is another single line command

Converted the ascii table to markdown table for nicer viewing. The minus sign can be interpreted as nothing or whitespace.

Config to reproduce error:

[scripts.1-test-single-line]
alias = '1-test-single-line'
command = '''
echo this is a single line command
'''

[scripts.2-test-multi-line]
alias = '2-test-multi-line'
command = '''
echo This
echo is
echo over
echo multiple
echo lines
'''

[scripts.3-test-another-single-line]
alias = '3-test-another-multi-line'
command = '''
echo this is another single line command
'''

pier rename/mv subcommand

Example usage

pier rename <original> <new>
with the alias:
pier mv <original> <new>

Warnings

The subcommand should not allow you to write over an existing script, but we could perhaps add a -f / --force flag. This is something that could be useful for the add command as well.

Attempting to run `pier list` segfaults straight away

Hello,
Unfortunately, when I attempt to run pier list it simply segfaults:

zsh โฏ pier list
[1]    503177 segmentation fault (core dumped)  pier list

From syslog:

2024-01-20T10:45:50.051578-06:00 mosthated-pc kernel: [ 3786.184976] pier[503177]: segfault at 89 ip 0000561acae62840 sp 00007ffd0699a570 error 4 in pier[561acae22000+ea000] likely on CPU 19 (core 3, socket 0)
2024-01-20T10:45:50.051588-06:00 mosthated-pc kernel: [ 3786.184985] Code: 73 08 31 c9 45 31 d2 eb 46 90 49 89 d0 49 83 e0 fc 4c 8d 8e 10 01 00 00 31 c9 45 31 d2 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 <49> 03 89 28 ff ff ff 49 03 89 70 ff ff ff 49 03 49 b8 49 03 09 49

I only just installed it and attempted to run pier config-init then was trying other commands, one being list which lead the the segfault.

I checked my config and there was not an interpreter, so I set it and my config looks like this:

[scripts.hello-pier]
alias = 'hello-pier'
command = 'echo Hello, Pier!'
description = 'This is an example command.'

[default]
interpreter = ["/bin/bash", "-c"]
System Details
OS: Ubuntu 23.10 x86_64
Host: X670E Taichi
Kernel: 6.5.0-14-generic
Uptime: 1 hour, 9 mins
Packages: 3591 (dpkg), 73 (flatpak), 27 (snap)
Shell: zsh 5.9
Resolution: 2560x1080
DE: GNOME 45.2
WM: Mutter
WM Theme: Adwaita
Theme: Yaru-dark [GTK2/3]
Icons: Yaru [GTK2/3]
Terminal: alacritty
CPU: AMD Ryzen 9 7950X (32) @ 5.881GHz
GPU: AMD ATI Radeon RX 6800/6800 XT / 6900 XT
GPU: AMD ATI 5a:00.0 Raphael
Memory: 13501MiB / 63398MiB

wrong tag with v1.5

๐Ÿ‘‹ looks like there is wrong tag with v1.5.

image

Also can you mark v0.1.5 as latest release? Thanks!

Pier copy/cp subcommand

Example usage

pier copy <original> <new>
with the alias:
pier cp <original> <new>

Warnings

The subcommand should not allow you to write over an existing script, but we could perhaps add a -f / --force flag. This is something that could be useful for the add command as well.

Show output to stderr as it happens.

I'm using a shell script managed by pier to perform various update tasks. One of these tasks is running rustup update. Currently, when I run this script, some of the progress output goes to stderr and is only visible after the whole script finishes. I think it would be better to show stderr output as it is produced by the script subprocess.

I think the issue might stem from this line.

Lacking lib.rs for unit testing.

Most of the code in main.rs should probably be moved into lib.rs so it's possible to create unit tests for the code.

I could start working on this next time I get a chance to sit down and do some coding.

`cargo test` fails when ran in fish shell

I tried to compile pier and one of the tests was failing. It turns out it depends on the user's current shell, which in my case is fish. Doing SHELL="/bin/bash" cargo test made them pass.

It makes sense that pier defaults to $SHELL to run scripts, but the tests probably shouldn't depend on the user's shell :)

Script base templates for new scripts

An option to allow new scripts to be started from a base template when adding a new script using your $EDITOR instead of specifying the command in the commandline.

The template would really just be a dumb file that is inserted into the new script as a base, an example base template could look like this:

 tmpfile=$(mktemp)
 trap 'rm "$tmpfile"' 0 1 15

 # --- continues ---
Flag short / long name

I would suggest -T / --template since tag is already taken.

How would this look in practice?

A pier command using the templating flag could perhaps look something like this:
pier add -a my_alias --template sh-tmpfile

T

[scripts.refresh-wifi] command = "ip link set wlp58s0 down && sleep 5 && ip link set wlp58s0 up" [scripts.twa-analyze] command = "docker run --rm -t trailofbits/twa -vw" tags = [ "infosec" ] [scripts.enabled-services] command = "systemctl list-unit-files --state=enabled" [scripts.flush-docker] command = "docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes" description = "A script to clear out old Docker containers and images" tags = [ "docker", "flush" ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.