From 88df5c72a317cc011f221627a2c3082078237cc1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 17 Jul 2018 23:37:20 -0700 Subject: Updating lib to v2 --- lib/file_hash.nom | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/file_hash.nom') diff --git a/lib/file_hash.nom b/lib/file_hash.nom index 9882481..542b2f2 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,10 +1,10 @@ -#!/usr/bin/env nomsu -V1 +#!/usr/bin/env nomsu -V2.2.4.3 # This file defines some actions for hashing files and looking up files by hash. use "core" -action [file with hash %hash] +action [file with hash %hash]: lua> ".." local Hash = require("openssl.digest") for filename in io.popen('find -L . -not -path "*/\\\\.*" -type f -name "*.nom"'):lines() do @@ -18,11 +18,11 @@ action [file with hash %hash] end end -action [hash %, sha1 %] +action [hash %, sha1 %]: %hashlib <- (=lua "require('openssl.digest')") %hash <- (=lua "\%hashlib.new('sha1'):final(\%)") - return: =lua "\%hash:gsub('.', function(c) return string.format('%02x', string.byte(c)) end)" - -parse [hash of file %filename] as - sha1: =lua "io.open(\%filename):read('*a')" + return (..) + =lua "\%hash:gsub('.', function(c) return string.format('%02x', string.byte(c)) end)" +parse [hash of file %filename] as (..) + sha1 (=lua "io.open(\%filename):read('*a')") -- cgit v1.2.3