Simpler and more powerful replacement for `find`

Overview

FindFile (FF)

An simple, ergonomic, and powerful replacement for find.

Note: this repo is under active development

The syntax is (mostly) figured out, but the internals and implementations of the syntax need a lot of work.

Road Map

  • Basic Lexer
    • string literals (with interpolation): "..."
    • perl regex literals (with interpolation): $/.../
    • path literals (sorta with interpolation): foo/*.txt
    • filesize literals: 12kb, 4.9mib
    • $env vars and $1 cli vars
    • date & time literals
    • have + in path literals start at the search root, not always at pwd root.
  • [~] Basic AST Builder
    • math & logic binary operators (most dont work in the runtime)
    • blocks of code
    • basic assignment
    • -Xk and +Xk need to be implemented for larger & smaller
    • compound assignment
    • logical assignment
    • arrays & hashmaps (they'll be the same, type)
    • function calls
    • function declarations
  • Basic Runtime
    • Figure out starting position (mostly works)
    • Add in basic math for most types
    • Cleanup how variables are accessed
    • Support ^{} and ${} for begin and end blocks
    • A way to convert to and from different types
    • Add more supported functions
      • Fill out the ones already in this file
      • Addd depth and "amount of children in directory"
    • Convert it to a vm
      • add in a JIT
  • Argument Parser
    • Most arguments (both currently implemented and todos) are added
    • An option to print out matched lines in their files (a-la ripgrep)
    • Clean it up to make it look really pretty (clap mostly does a good job)
  • Misc
    • Optimize file reading so you dont read an entire file to math the first line
    • cleanup type represenations
    • maybe remove the significant bits from filesizes?
    • Solidify when I'm using Vec<u8> vs OsString vs String.
    • Figure out how to reconcile ${} for begin blocks and ${} for env vars
    • should unknown variables warn?

Here's some examples of things I want to eventually support

  • list all files in a directory: ff 'isfile && depth=1'
  • make a "tree" of files and their directories: ff -n 'print "\t"*depth_from(start), basename'
  • find all files that're at least 1 gig or are newer than 10 days ago: ff 'size > 1g || modify > -10d'
  • add the suffix -YYYY-MM-DD to all files but keep the extension: ff -n 'isfile && mv(file, "{dir}{base}-{ymd_date}.{suffix})'
  • find files newer than 10 days with the enclosing folder is log: ff 'isfile && modify > -10d && basename(parent) = "log"'
  • find all files that contain "hello" and "world", possibly on separate lines: ff 'contents =~ /hello/ && contents =~ /world/'
  • find the largest folder by its immediate files: (${} is run at script end): ff -n '${print maxdir} dirsize > dirsize(maxdir) then maxdir=dirsize'

Keywords

  • true equivalent to 1
  • false equivalent to 0

if else while continue break def return skip/next

Functions

If a function takes no arguments, you can just omit the parens. eg file? is the same as file?(), as file?() is equivalent to file?(path).

Querying Info

name and args aliases what it does
file?(p=path) f? Returns whether p is a file.
directory?(p=path) d? dir? Returns whether p is a directory.
executable?(p=path) e? exe? Returns whether p is an executable.
symlink?(p=path) s? sym? Returns whether p is a symlink.
binary?(p=path) b? bin? Returns whether p is a binary file.
gitignore?(p=path) gi? Returns whether p is ignored by a gitignore file.
hidden?(p=path) gi? Returns whether p is starts with .
ok?(msg) Prints msg out, then asks for confirmation.
macos(...) future idea: stuff like macos tags or whatnot

Path-Related functions

| root() | r | The root folder we started looking at | | path() | p | The current path | | dirname(p=path) | d dir parent | The parent directory | | extname(p=path) | e ext extension | The extension, without a . if it's present | | extnamed(p=path) | ed extd extensiond | The extension, including the . if it's present. | | basename(p=path) | b bn base | Everything but the parent directory of p | | stemname(p=path) | s stem | basename, except without an extension (if present) |

Misc

| print(...) | pr | Prints its arguments out (with nothing between them) followed by a newline | | printn(...) | prn | Prints its arguments out (with nothing between them) without a newline | | next | skip | Ignores the current argument and continues onwards | | exit(status) | quit | stops the entire script | | pwd() | Current working directory | | depth(src=path, dst=root) | how many directories down we are from the dst. | | date(<...>) | The current date foromatted in a time | | sleep(<...>) | Sleeps |

Executable functions

Some of these functions are "destructive" (such as mv): If a destructive file would overwrite another one, it'll check the command line arguments to see what to do (--interactive implies always ask, --force implies never ask; if neither is given, --force is assumed.) You can use <fn>i to always do interactive or <fn>f to always force (like mvf).

All these must be called with parens (maybe?)

name and args what it does
exec(...) ..
mv{,f,i}(src=path, dst) Moves src to dst; only confirms if overwriting a file when interactive
rm{,f,i}(src=path) Removes the file at src; always confirms when interactive. If given an empty directory, rm acts like rmdir.
rmr{,f,i}(src=path) Removes the file at src, recursively; always confirms when interactive
cp{,f,i}(src=path, dst) Copies src to dst only confirms if overwriting a file when interactive
ln...
mkdir(p) Creates a directory at p; It'll also make all parent directories.
touch(src=path) Creates a directory at p; It'll also make all parent directories.

IDEAS:

there was a problem with moving your file. What would you like to do: (Q)uit: Stop the entire program (C)ontinue: continue onwards, (R)etry: try it again (maybe after you fix something) (S)hell: Drop you into a shell where $cpath is the variable for the current path

You might also like...
fastmod is a fast partial replacement for the codemod tool

fastmod is a fast partial replacement for codemod. Like codemod, it is a tool to assist you with large-scale codebase refactors, and it supports most of codemod's options.

A readline replacement written in Rust

A readline replacement written in Rust Basic example // Create a default reedline object to handle user input use reedline::{DefaultPrompt, Reedline,

Fls - Ferris-LS, a very bad LS replacement. Besides that, proves that I suck at clean & good code.

FLS A handy ls remake, purely for learning. Why FLS? There's no reason, at all, don't use it. I just want to learn Rust :D Usage Flags: -i = Use icons

πŸ¦€οΈatos for linux by rust - A partial replacement for Apple's atos tool for converting addresses within a binary file to symbols.

atosl-rs πŸ¦€οΈ atos for linux by rust - A partial replacement for Apple's atos tool for converting addresses within a binary file to symbols. tested on

xcp is a (partial) clone of the Unix cp command. It is not intended as a full replacement

xcp is a (partial) clone of the Unix cp command. It is not intended as a full replacement, but as a companion utility with some more user-friendly feedback and some optimisations that make sense under certain tasks (see below).

drop-in replacement for libfuzzer
drop-in replacement for libfuzzer

Fazi A reimplementation of libfuzzer in Rust with some improvements Supported Features libFuzzer's mutations SanCov feedback Building without a main()

Xcode Neovim Replacement-ish.
Xcode Neovim Replacement-ish.

An XCode replacement-ish development environment that aims to be your reliable XCode alternative to develop exciting new [apple] software products πŸš€

A lightweight, no-fuss, drop-in replacement for Rudderstack

Welcome to Stilgar! Stilgar is a lightweight, no-fuss, drop-in replacement for Rudderstack. Key features: Seamlessly compatible with all Rudderstack c

A modern, maintained replacement for ls
A modern, maintained replacement for ls

eza eza is a modern, maintained replacement for ls, built on exa. README Sections: Options β€” Installation β€” Development eza is a modern, maintained re

Owner
Sam Westerman
I'm a full-stack software dev that loves computer science. I'm currently working a variety of programming languages.
Sam Westerman
fas stand for Find all stuff and it's a go app that simplify the find command and allow you to easily search everything you nedd

fas fas stands for Find all stuff and it's a rust app that simplify the find command and allow you to easily search everything you need. Note: current

M4jrT0m 1 Dec 24, 2021
A more convenient `#[target_feature]` replacement

A more convenient #[target_feature] replacement To get good performance out of SIMD everything on the SIMD codepath must be inlined. With how SIMD is

Koute 3 Apr 10, 2023
fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find

fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find. While it does not aim to support all of find's powerful functionality, it provides sensible (opinionated) defaults for a majority of use cases.

David Peter 25.9k Jan 9, 2023
🧠 A command-line utility for switching git branches more easily. Switch branches interactively or use a fuzzy search to find that long-forgotten branch name.

git-smart-checkout A git command extension for switching git branches more efficiently. About Interactively switch branches or fuzzy search for that f

Cezar Craciun 51 Dec 29, 2022
A drop-in replacement for `dapp` and `seth` in Rust

dapptools.rs Rust port of DappTools dapp example Usage Run Solidity tests Any contract that contains a function starting with test is being tested. Th

Georgios Konstantopoulos 5k Jan 1, 2023
Patch binary file using IDA signatures and defined replacement bytes in YAML.

fabricbin Patch binary file using IDA signatures and defined replacement bytes in YAML. Install: cargo install --git https://github.com/makindotcc/fab

makin 3 Oct 24, 2023
A lightweight but incredibly powerful and feature-rich BitTorrent tracker. Supports UDP + HTTP(S) and a private tracker mode.

Torrust Tracker Project Description Torrust Tracker is a lightweight but incredibly powerful and feature-rich BitTorrent tracker made using Rust. Feat

Torrust 162 Dec 31, 2022
exa is a modern replacement for ls.

exa exa is a modern replacement for ls. README Sections: Options β€” Installation β€” Development exa is a modern replacement for the venerable file-listi

Benjamin Sago 20.3k Jan 8, 2023
zoxide is a blazing fast replacement for your cd command

zoxide A smarter cd command for your terminal zoxide is a blazing fast replacement for your cd command, inspired by z and z.lua. It keeps track of the

Ajeet D'Souza 8.7k Dec 31, 2022
procs is a replacement for ps written in Rust.

procs is a replacement for ps written in Rust. Documentation quick links Features Platform Installation Usage Configuration Features Output by t

null 3.6k Dec 30, 2022