Skip to content

Technius/tempget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tempget

build status

Tempget is a cross-platform CLI utility program that downloads (and possibly extracts) files into locations specified by a "template" file. Tempget can download files in parallel, and it provides a nice command line interface with progress indicators.

demo

Examples of use cases:

  • You want to download a bunch of programs from many different websites. However, you might need to do this multiple times, so instead of doing it manually, you create a template file that lists all of the URLs and run tempget to download them for you, in parallel.
  • You're writing a script that needs to download and extract files at some point. Instead of writing download and extract commands manually, you create a template file and call tempget in the script.
  • To install a mod for a game, you need to download a large number of assets from the internet, and they need to be placed in specific locations. You can simplify the installation process by creating a template file and using tempget to download and place the assets.

You can think of Tempget as "Template Getter" (automate your downloads by using a template file to specify where to download the files from and where to place them) or "Temporary Getter" (write your template file, download Tempget, run it on your template, and then delete Tempget).

Features

  • Human-friendly CLI with progress indicators
  • Create template files to automatically specify what files to retrieve and where to place them
  • Selectively extract files from .zip archive files into desired locations
  • Parallel file downloads
  • Template files are specified in TOML and can be easily generated by another program
  • Cross-platform with zero dependencies: works on Windows, Mac, and Linux!

Installation

Pre-compiled Linux binaries are available on the Releases page.

If you are on Mac/Windows or you want to compile from source, run

cargo install --git https://github.com/Technius/tempget --tag latest-release

Remove the --tag <version> part to install the latest development version.

Usage

First, create a template file. Templates use the TOML configuration format.

Template file format

The retrieve section describes which files to download and where to place them. For example, the following template will download two files from the specific URLs and save them to my_file and some_folder/other_file:

[retrieve]

# Format is
#     "location_on_disk" = "https://link_to_file"

"my_file" = "https://example.com/"
"some_folder/other_flie" = "https://example.com/some_file"

The extract section describes how to extract files from an archive, using the zip archive files as keys. At the moment, each zip file can be handled in one of two ways:

  • Extracting all of the contents of the zip file to a folder. The zip file should be mapped to the location of the folder to extract to:

    [extract]
    "my_zip_file.zip" = "somewhere/folder_to_extract_to/"
  • Extracting some files to particular locations. The name of the zip file should be a subsection of the extract section; this subsection maps files in the zip archive to the locations to extract to:

    [extract."my_zip_file.zip"]
    "folder_in_zip/file_in_zip" = "somewhere/file_to_extract_to"
    "other_file_in_zip" = "another_file_to_extract_to"

Running the template download

Once you have created your template file, run

tempget template.toml

where template.toml is the name of your template file. You can configure what tempget does by supplying command line flags; see tempget -h for more information.

Frequently Asked Questions

Why would I want to use Tempget instead of a shell script?

To the best of our knowledge, Tempget is cross-platform while there are no built-in cross-platform tools. or scripting languages that support the same functionalities. It might be possible to write a similar tool in a cross-platform scripting language such as Python, JavaScript, or Ruby, but it is very likely that such a language must be installed before the language can be used (e.g. Windows does not come with Python installed).

Additionally, for simple file download tasks, it becomes very tedious to write scripts to download files to specific locations--especially if some files are contained in zip files.

Why would I want to use a shell script instead of Tempget?

Tempget is primarily for downloading files to specific locations. More complex actions, such as executing arbitrary commands after downloading, can and should be achieved with your choice of scripting language. If you need to extract all files of a specific file format from a zip file and then post-process them, you're probably better off writing a shell script. If you need to download and compile code source, you're probably better off writing a shell script.

Of course, you can always use tempget as part of a script.

Why is Tempget's file size so large?

To make the implementation simpler, Tempget uses many libraries. Since Tempget is implemented in Rust, all of these libraries are statically linked into the final tempget binary. This means that Tempget can run almost anywhere, but at the cost of larger file sizes.

License

Copyright 2018-2019 Bryan Tan ("Technius")

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.