devmatteini / dra

A command line tool to download release assets from GitHub
MIT License
185 stars 8 forks source link

is there any support or way to use for `.7z` files? #235

Closed candrapersada closed 1 month ago

candrapersada commented 1 month ago

is there any support or way to use --install for .7z files? and how to use for ffmpeg.exe ffplay.exe and ffprobe.exe one download?

devmatteini commented 1 month ago

Hi @candrapersada!

is there any support or way to use --install for .7z files?

Currently no, but I think it can be added. Can you share repositories that distribute .7z files in their releases?

and how to use for ffmpeg.exe ffplay.exe and ffprobe.exe one download?

I'm not sure what you mean. If you want to download and install executable files check out examples

candrapersada commented 1 month ago

https://github.com/AnimMouse/ffmpeg-stable-autobuild/releases/download/2024-10-05-20-03-a319c0f-7.1/ffmpeg-7.1-a319c0f-win64-nonfree.7z

https://github.com/shinchiro/mpv-winbuild-cmake/releases/download/20241023/mpv-x86_64-20241023-git-165159f.7z

https://github.com/FreeTubeApp/FreeTube/releases/download/v0.21.3-beta/freetube-0.21.3-win-x64-portable.7z

devmatteini commented 1 month ago

Hi @candrapersada! You can download latest release 0.6.3 to install from 7-Zip files.

In order to work, you need to install 7z and make sure it's available in your PATH.

Let me know if there are any issues!

candrapersada commented 1 month ago

how to update from 0.6.2 to 0.6.3?

devmatteini commented 1 month ago
candrapersada commented 1 month ago

will there be a feature to update dra easily without manually moving ./dra new somewhere in PATH?

devmatteini commented 1 month ago

I don't think so. The way you update dra depends on how you installed it, and dra doesn't know how you installed it.

If you used a package manager, like Homebrew or pacman, use that to update dra. If you installed a prebuild binary, you have to do the commands I explained before. If you installed a debain package, you have to download and install it.

candrapersada commented 1 month ago
dra download -a -i devmatteini/dra
./dra --version
# should print 0.6.3
Error copying C:\Users\Username\AppData\Local\Temp\dra-9234acf0aee64a40ad801a7fb1eaf858\dra-0.6.3-x86_64-pc-windows-msvc\dra.exe to C:\Users\Username\bin\dra.exe:
  The process cannot access the file because it is being used by another process. (os error 32)
devmatteini commented 1 month ago

I suppose you are in this directory: C:\Users\Username\bin where dra is located.

You cannot replace dra with a new version while the dra process is running.

You need to go to another directory, run the dra command I told you and then move the new dra.exe to C:\Users\Username\bin

candrapersada commented 1 month ago

is it possible to add dra-x86_64-pc-windows-msvc.zip without the version number in the release so I can use this curl -L "https://github.com/devmatteini/dra/releases/latest/download/dra-x86_64-pc-windows-msvc.zip" -o "dra-x86_64-pc-windows-msvc.zip" to download if dra is not on PATH? like curl -L "https://github.com/devmatteini/dra-tests/releases/latest/download/helloworld.zip" -o "helloworld.zip"

devmatteini commented 1 month ago

I use this on linux for the first time dra installation: https://github.com/devmatteini/dotfiles/blob/7fe2d8af46e21364386c8bbc9850576226ed2289/bootstrap/dependencies.sh#L18-L23

You can modify it to work on windows.

To update it I use dra download -a -i devmatteini/dra && mv dra ~/.local/bin

candrapersada commented 1 month ago
  # Download latest linux musl release asset (https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8)
  curl -s https://api.github.com/repos/devmatteini/dra/releases/latest \
  | grep "browser_download_url.*x86_64-unknown-linux-musl" \
  | cut -d : -f 2,3 \
  | tr -d \" \
  | wget -O "$ARCHIVE" -i -

how to use in windows?

devmatteini commented 1 month ago

In git bash you can use it like this:

curl -s https://api.github.com/repos/devmatteini/dra/releases/latest \
  | grep "browser_download_url.*x86_64-pc-windows-msvc" \
  | cut -d : -f 2,3 \
  | tr -d \" \
  | xargs -I {} curl -Lo dra.zip {}

I don't use windows very often so I can't help you with powershell or command prompt.

But again I'm not quite sure what you are trying to solve. If you try to explain your problem, maybe I can help you.

candrapersada commented 1 month ago

install and update dra without using a browser by using a .bat file or .sh file

devmatteini commented 1 month ago

If you use a .sh file, use the above script:

curl -s https://api.github.com/repos/devmatteini/dra/releases/latest \
  | grep "browser_download_url.*x86_64-pc-windows-msvc" \
  | cut -d : -f 2,3 \
  | tr -d \" \
  | xargs -I {} curl -Lo dra.zip {}

This will install and update dra to the latest version available.

candrapersada commented 1 month ago

how to use wget curl script

function download {
    url=$1
    filename=$2

    if [ -x "$(which wget)" ] ; then
        wget -q $url -O $2
    elif [ -x "$(which curl)" ]; then
        curl -o $2 -sfL $url
    else
        echo "Could not find curl or wget, please install one." >&2
    fi
}
# to use in the script:
download https://url /local/path/to/download

from linux or windows

devmatteini commented 1 month ago
function download_dra() {
  filename=$1

  TMP_DIR=$(mktemp --directory)
  ARCHIVE="$TMP_DIR/dra.zip"

  curl -s https://api.github.com/repos/devmatteini/dra/releases/latest \
  | grep "browser_download_url.*x86_64-pc-windows-msvc" \
  | cut -d : -f 2,3 \
  | tr -d \" \
  | xargs -I {} curl -Lo "$ARCHIVE" {}

  unzip -j "$ARCHIVE" -d "$TMP_DIR"
  mv "$TMP_DIR"/dra.exe "$filename"
}

download_dra "/some/path/to/dra.exe"

Once you have dra installed, you can you use it to download other tools from GitHub.

candrapersada commented 1 month ago

what I mean is Trying to do a script to download a file using wget, or curl if wget doesn't exist in Linux and Windows. How do I have the script check for existence of wget?

    if [ -x "$(which wget)" ] ; then
        wget -q $url -O $2
    elif [ -x "$(which curl)" ]; then
        curl -o $2 -sfL $url
    else
        echo "Could not find curl or wget, please install one." >&2
    fi

download_dra

devmatteini commented 1 month ago

You should search that question on google: https://stackoverflow.com/questions/592620/how-can-i-check-if-a-program-exists-from-a-bash-script

If you have questions related to dra I will help you further, otherwise sorry but I don't have time to help you.

candrapersada commented 1 month ago

how to clean TMP_DIR aftar download

devmatteini commented 1 month ago

You don't have to. Temporary files are deleted automatically on a regular basis