Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 2.74 KB

CONTRIBUTING.md

File metadata and controls

43 lines (35 loc) · 2.74 KB

Welcome! Here be a general repo overview to serve as an intro to a young lady or gentleman who is considering reading up on they things are set up around here and possibly contributing.

Conventions

Everything is go fmt and go lint compliant. All the major editors support plugins that enable doing this on the fly, they are very helpful.

Another useful tool that I found helpful is goimports.

At the moment I want to move to maximum modularity, so that each separate functionality domain is moved into its own separate package. I have heard of people arguing that it is not sustainable but not yet convinced. Maybe this will fail and that would be my way to grok their argument.

Intro Walkthrough & Concepts

###Mode

mode *Mode, defined in arguments.go, stores all things involving the settings of the running instance:

  type Mode struct {
    inputPath  string // target path literal from the argument parsing (e.g. "~/hi")
    absolutePath string // absolute path to the target directory (e.g. "/home/dima/hi")
    // ...
    // and ... boolean flags for specific modes
  }

We have target directory's path here and all the mode flags.

ParseArguments() parses the arguments passed on to lsp into mode flags and target dir. There are many excellent libraries that parse flag arguments, I ended up rewriting my own to enable ls-style single letter triggers within one flag (so that lsp -al is equivalent to lsp -a -l or lsp -la).

Breakdown of Contents

See godocs.org:

  • lsp.go contains main() function
  • arguments.go parses arguments in order inferring the target path and flags invoked to the best of its ability.
  • fileinfo.go contains FileInfo struct with what is known of individual file/folder in the list and methods to fetch this info
  • filelist.go contains Filelist []Fileinfo definition and methods to do the two tasks: filter, sort and represent as appropriate to the running mode (flags)
  • fmt.go, complements render.go, containing stuff to format output in the stdoutt/terminal, but fmt.go is for more bash-specific/lower level stuff
  • investigate.go contains functions to "investigate" individual files for type, size, binary/text directories for character of their content and so on
  • paths.go contains filesystem path parsing and manipulation operations
  • sort.go contains mode-specific file sorting interface implementations
  • traverse.go: traverse group Trie and select representation grouping
  • trie.go contains a Trie of grouped/classified files with attributes as nodes. Root node has 3 parents: directories, reg. files and special files (everything else, like symlinks, devices and so on) it goes down up to file extension, modification time and so on.