Skip to content

Commit

Permalink
add lib downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
WindSoilder committed Aug 7, 2022
1 parent 1f5bd90 commit f4fac3c
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions downloader.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
def find-plugin-path [] {
open $nu.plugin-path | find nu_plugin_bin_reader | split column ' ' | get column2 | ansi strip | get 0
}

export def all-libs [] {
[
"android_bootldr_asus", "android_bootldr_huawei", "android_bootldr_qcom", "android_img",
"android_nanoapp_header", "android_opengl_shaders_cache", "android_sparse", "android_super",
"dex", "android_dto", "chrome_pak", "cpio_old_le", "gzip", "lzh", "mozilla_mar",
"phar_without_stub", "rar", "rpm", "xar", "zip", "zisofs", "bcd", "bytes_with_io",
"dos_datetime", "riff", "utf8_string", "vlq_base128_be", "vlq_base128_le", "dbf", "gettext_mo",
"sqlite3", "tsm", "dos_mz", "mbr_partition_table", "vfat", "elf", "java_class", "mach_o",
"microsoft_pe", "python_pyc_27", "swf", "uefi_te", "apm_partition_table", "apple_single_double",
"btrfs_stream", "cramfs", "ext2", "gpt_partition_table", "iso9660", "luks", "lvm2", "tr_dos_image",
"vdi", "vmware_vmdk", "zx_spectrum_tap", "andes_firmware", "broadcom_trx", "ines", "uimage",
"grub2_font", "pcf_font", "ttf", "allegro_dat", "doom_wad", "dune_2_pak", "fallout2_dat",
"fallout_dat", "ftl_dat", "gran_turismo_vol", "heaps_pak", "heroes_of_might_and_magic_agg",
"heroes_of_might_and_magic_bmp", "minecraft_nbt", "quake_mdl", "quake_pak", "renderware_binary_stream",
"saints_row_2_vpp_pc", "warcraft_2_pud", "shapefile_index", "shapefile_main", "dtb", "edid",
"mifare_classic", "bmp", "dicom", "exif", "gif", "gimp_brush", "icc_4", "ico", "jpeg", "nitf",
"pcx", "pcx_dcx", "png", "psx_tim", "tga", "wmf", "xwd", "glibc_utmp", "sudoers_ts", "systemd_journal",
"aix_utmp", "hashcat_restore", "mcap", "windows_evt_log", "compressed_resource", "dcmp_0", "dcmp_1",
"dcmp_2", "dcmp_variable_length_integer", "ds_store", "mac_os_resource_snd", "resource_fork", "au", "avi",
"blender_blend", "creative_voice_file", "fasttracker_xm_module", "genmidi_op2", "id3v1_1", "id3v2_3",
"id3v2_4", "magicavoxel_vox", "ogg", "quicktime_mov", "s3m", "standard_midi_file", "stl", "vp8_ivf",
"wav", "bitcoin_transaction", "dime_message", "dns_packet", "ethernet_frame", "hccap", "hccapx", "icmp_packet",
"ipv4_packet", "ipv6_packet", "microsoft_network_monitor_v2", "packet_ppi", "pcap", "protocol_body",
"rtcp_payload", "rtp_packet", "rtpdump", "some_ip", "some_ip_container", "some_ip_sd", "some_ip_sd_entries",
"some_ip_sd_options", "tcp_segment", "tls_client_hello", "udp_datagram", "websocket", "avantes_roh60", "nt_mdt",
"nt_mdt_pal", "specpr", "efivar_signature_list", "openpgp_message", "ssh_public_key", "asn1_der", "bson",
"google_protobuf", "microsoft_cfb", "msgpack", "php_serialized_value", "python_pickle", "ruby_marshal", "regf",
"windows_lnk_file", "windows_minidump", "windows_resource_file", "windows_shell_items", "windows_systemtime"
]
}

export def get-lib-path [name: string] {
let plugin_dir = (find-lib-path | path dirname)
$plugin_dir | path join "reader" $"($name).py"
}

export def fetch-bin-lib [name: string] {
echo $"going to download lib ($name)"
let url = $"https://formats.kaitai.io/($name)/src/python/($name).py"
let content = fetch $url
let target_path = get-lib-path $name
echo $"download complete, save it to ($target_path)"
$content | save $target_path
echo "done"
}

export def remove-lib [name: string] {
let lib_path = get-lib-path $name
if ($lib_path | path exists) {
rm $lib_path
} else {
error make -u {msg: $"Library ($name) is not exists"}
}
}

export def remove-all-libs [] {
let plugin_dir = (find-lib-path | path dirname)
rm -rf ($plugin_dir | path join "reader" "*")
}

export def fetch-all-libs [] {
all-libs | each { |it| fetch-bin-lib $it }
}

0 comments on commit f4fac3c

Please sign in to comment.