All Projects → imdrasil → sam.cr

imdrasil / sam.cr

Licence: MIT license
Rake-like task manager

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to sam.cr

Mmake
Mmake is a small program which wraps make to provide additional functionality, such as user-friendly help output, remote includes, and eventually more. It otherwise acts as a pass-through to standard make.
Stars: ✭ 1,593 (+1819.28%)
Mutual labels:  task-manager
Wp Project Manager
The Project Management plugin for WordPress
Stars: ✭ 186 (+124.1%)
Mutual labels:  task-manager
todo-live
A todo list manager in command line.
Stars: ✭ 49 (-40.96%)
Mutual labels:  task-manager
Daybydaycrm
DaybydayCRM an open-source CRM, to help you keep track of your daily workflow.
Stars: ✭ 1,856 (+2136.14%)
Mutual labels:  task-manager
Vscode Journal
Lightweight journal and simple notes support for Visual Studio Code
Stars: ✭ 174 (+109.64%)
Mutual labels:  task-manager
Todo App
Simple ReactJs todo app ✍
Stars: ✭ 206 (+148.19%)
Mutual labels:  task-manager
Goodwork
Self hosted project management and collaboration tool powered by TALL stack
Stars: ✭ 1,730 (+1984.34%)
Mutual labels:  task-manager
fastlane
Fastlane is a redis and docker based queueing service.
Stars: ✭ 48 (-42.17%)
Mutual labels:  task-manager
Kreta
Modern project management solution
Stars: ✭ 177 (+113.25%)
Mutual labels:  task-manager
Ten Hands
⚡ Simplest way to organize and run command-line tasks
Stars: ✭ 228 (+174.7%)
Mutual labels:  task-manager
Vim Bujo
A minimalist task manager for vim.
Stars: ✭ 136 (+63.86%)
Mutual labels:  task-manager
Pypyr
pypyr task-runner cli & api for automation pipelines. Automate anything by combining commands, different scripts in different languages & applications into one pipeline process.
Stars: ✭ 173 (+108.43%)
Mutual labels:  task-manager
Geek Life
The Todo List / Task Manager for Geeks in command line
Stars: ✭ 212 (+155.42%)
Mutual labels:  task-manager
Naruto
An object-oriented multi process manager for PHP 🤖
Stars: ✭ 129 (+55.42%)
Mutual labels:  task-manager
majordodo
Distributed Operations and Data Organizer built on Apache BookKeeper
Stars: ✭ 25 (-69.88%)
Mutual labels:  task-manager
Unfog
⏱ Minimalist CLI task & time manager, written in Haskell.
Stars: ✭ 121 (+45.78%)
Mutual labels:  task-manager
Kronos.vim
A simple task and time manager. Project moved here:
Stars: ✭ 205 (+146.99%)
Mutual labels:  task-manager
obsidian-success-plan
Manage your tasks, projects, key results, and goals within Obsidian. This plugin follows #theGamificationProject's Success Plan Framework.
Stars: ✭ 29 (-65.06%)
Mutual labels:  task-manager
calcure
Modern TUI calendar and task manager with minimal and customizable UI.
Stars: ✭ 1,071 (+1190.36%)
Mutual labels:  task-manager
Dramatiq
A fast and reliable background task processing library for Python 3.
Stars: ✭ 2,844 (+3326.51%)
Mutual labels:  task-manager

Sam Build Status Latest Release

Sam is a Make-like utility which allows to specify tasks like Ruby's Rake do using plain Crystal code. This allows you to reuse existing application code base and/or include tasks from your dependencies.

Installation

Add this to your application's shard.yml:

dependencies:
  sam:
    github: imdrasil/sam.cr
    version: 0.4.2

After executing shards install Sam-file will be added to the root of your project (unless you already have one).

Usage

Task

Tasks are the main unit in sam.cr. Task has a name, a list of prerequisites and a list of actions (block of a code).

Sam extends the global context with own DSL. To define a task use task method which accepts the task name as the 1st argument.

task "name" do
end

If you want to define prerequisites, add the array with their names as the 2nd argument:

task "name", ["prereq1", "prereq2"] do
end

Executing a task

Sam does no magic with your sam.cr file - it is just a common .cr source file which allows you to recompile it with any possible code you want such amount of times you need. Therefore the most obvious way to execute any task is:

$ crystal sam.cr name

In addition to this you are able to configure your makefile to invoke sam tasks. This allows you to use shorten variant

$ make sam name

To automatically modify your Makefile run

$ crystal sam.cr generate:makefile

This will modify existing Makefile or create new one. Be careful - this will silent all nonexisting makefile tasks on invocation.

To see a list of all available tasks with their descriptions:

$ crystal sam.cr help

Tasks with arguments

To pass arguments to your task just list them after it's name:

$ crystal sam.cr name john rob ned

They are passed to a task as a 2nd block argument.

task "name" do |_, args|
  puts args[0].as(String)
end

args here is an instance of Sam::Args class that contains arguments and named arguments passed to each task. Any argument passed from a console is treated as a String but Int32 and Float64 values also can be specified during task invocation from inside of another one.

Each task has own collection of arguments; only prerequisites shares with target task same Args instance.

Named argument also can be specified by the following ways:

  • -argument value
  • -argument "value with spaces"
  • argument=value
  • argument="value with spaces"

Two important restriction with named arguments usage and makefile-style task invocation:

  • -- should be placed to explicitly specify that specified named arguments belongs to task not to Makefile:
$ make sam name john
$ # but
$ make same name -- argument=john
  • makefile doesn't support named arguments with = sign

To invoke More than one task list them one by one (including their arguments) separating them with @ symbol:

$ crystal sam.cr name john @ surname argument=snow

Accessing tasks programmatically

Sam allow you to invoke tasks within another ones and even passing own args object. To do this just call #invoke method with task name (and arguments if needed) on task object passed as 1st argument:

task "name" do |t|
  t.invoke("surname")
end

task "surname" do
  puts "Snow"
end

If specified task was already invoked before - it will be ignored. To force task invocation - use #execute.

Another task could be invoked from current using invoke method. It has next signatures:

Namespaces

as projects grow amount of defined tasks grow as well. To simplify navigation and increase readability tasks can be grouped in namespaces:

namespace "main" do
  task "build" do
    # Build the main program
  end
end

namespace "samples" do
  task "build" do
    # Build the sample programs
  end
end

task "build", %w[main:build samples:build] do
end

Name resolution

When task is invoked from other one, provided path will float up through current task namespace and search given task path on each level until top level. Task could have same name as any existing namespace.

task "one" do
end

namespace "one" do
  namespace "two"
    task "test" do |t|
      t.invoke("one")
    end
  end
end

In the example above next paths are checked (in given order):

  • one:two:one
  • one:one
  • one (as task not namespace)

Share tasks

Sam tasks can be loaded from installed dependencies. To do this helper macro load_dependencies can be used:

load_dependencies "lib1", "lib2"

This is translated to

require "./lib/lib1/tasks/sam.cr"

Development

Before running tests call

$ crystal examples/sam.cr setup

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • imdrasil Roman Kalnytskyi - creator, maintainer
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].