Skip to content

LilithHafner/BasicAutoloads.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BasicAutoloads

Build Status Coverage PkgEval Aqua

BasicAutoloads lets you say "whenever I type this in the REPL, run that for me". It's great for automatically loading interactive tools.

For example, put this in your startup.jl

if isinteractive()
    using BasicAutoloads
    register_autoloads([
        ["@b", "@be"]            => :(using Chairmarks),
        ["@benchmark"]           => :(using BenchmarkTools),
        ["@test", "@testset", "@test_broken", "@test_deprecated", "@test_logs",
        "@test_nowarn", "@test_skip", "@test_throws", "@test_warn", "@inferred"] =>
                                    :(using Test),
        ["about, @about"]        => :(using About; macro about(x) Expr(:call, About.about, x) end),
        ["pager"]                => :(using TerminalPager),
    ])
end

Add BasicAutoloads and any packages you want to automatically load to your default environment, and then enjoy the benefits at the REPL:

julia> Test
ERROR: UndefVarError: `Test` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

julia> @test 1+1 == 2 # Test is automatically loaded here
Test Passed

julia> Test
Test

Scripts and such will still need to explicitly load their deps.

For more details, see the docstring of register_autoloads


API design decisions

Accept a very narrow type signature to force folks to always use the same approach so that features are inherently discoverable. You are certian to know you can X if you are forced to do so all the time for X in

  • provide arbitrary exprs
  • provide multiple triggers for a single expr
  • provide macro names as strings instead of symbols

Trivial extensions that I opted not to do

  • Triggers are scalar or iterables of symbols or strings
  • Expres are symbols which expand to :(using Sym)

Simple, but nontrivial extensions

  • Regex as trigger
  • Function as trigger
  • Function (that possibly runs multiple times) as expr

About

"whenever I type this in the REPL, run that for me"

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages