Full Code of f/guardian for AI

master 8c1f129b829c cached
11 files
5.2 KB
1.6k tokens
1 requests
Download .txt
Repository: f/guardian
Branch: master
Commit: 8c1f129b829c
Files: 11
Total size: 5.2 KB

Directory structure:
gitextract_w7gqioyv/

├── .github/
│   └── workflows/
│       └── crystal.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── guardian.yml
├── install.sh
├── shard.yml
├── spec/
│   ├── guardian.cr
│   └── spec_helper.cr
└── src/
    └── guardian.cr

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/workflows/crystal.yml
================================================
name: Crystal CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  schedule:
    - cron: '0 5 * * 0'

jobs:
  build:

    runs-on: ubuntu-latest

    container:
      image: crystallang/crystal

    steps:
    - uses: actions/checkout@v2
    - name: Install dependencies
      run: shards install
    - name: Run build
      run: crystal build src/guardian.cr


================================================
FILE: .gitignore
================================================
/doc/
/libs/
/.crystal/
/.shards/
guardian


# Libraries don't need dependency lock
# Dependencies will be locked in application that uses them
/shard.lock


================================================
FILE: .travis.yml
================================================
language: crystal


================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2016 Fatih Kadir Akın

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


================================================
FILE: README.md
================================================
# 💂 Guardian.cr

Guardian watches over your files and runs assigned tasks.

![Guardian](http://i.imgur.com/mUzv2DL.gif)

## Installation

### OS X

```bash
brew tap f/guardian
brew install guardian
```

### Arch Linux

Guardian is availabe as a package from the Arch User Repository 
called [guardian-git](https://aur.archlinux.org/packages/guardian-git/)

### From Source

```bash
git clone https://github.com/f/guardian.git && cd guardian
crystal build src/guardian.cr --release
```

## Quickstart

### Crystal Libs

Guardian works seamless with Crystal Projects. It automatically binds itself to
library you use.

```bash
$ crystal init lib yourlib
$ cd yourlib
$ guardian --init
Created guardian.yml of ./src/yourlib.cr
```

### Non-Crystal Libs

You can use Guardian for other projects.

```bash
$ guardian --init
Created guardian.yml
```

## Usage

```bash
$ guardian --init
```

It will create a `guardian.yml` file to use by Guardian.

## `guardian.yml`

`guardian.yml` is a simple YAML file.

Simply it has **YAML documents** with seperated by `---` line and each document has
`files` and `run` keys.

`files` key needs a glob pattern, and `run` is a shell command what to run.

```yaml
files: ./**/*.cr
run: crystal build ./src/guardian.cr
---
files: ./shard.yml
run: shards install
```

### `%file%` Variable

Guardian replaces `%file%` variable in commands with the changed file.

```yaml
files: ./**/*.txt
run: echo "%file% is changed"
```

Think you have a `hello.txt` in your directory, and Guardian will run `echo "hello.txt is changed"` command when it's changed.

## Running Guardian

```bash
$ guardian
💂 Guardian is on duty!
```

## Contributing

1. Fork it ( https://github.com/f/guardian/fork )
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

- [f](https://github.com/f) Fatih Kadir Akın - creator, maintainer


================================================
FILE: guardian.yml
================================================
files: ./**/*.cr
run: crystal build ./src/guardian.cr
---
files: ./shard.yml
run: shards install


================================================
FILE: install.sh
================================================
#!/bin/bash

# for linux users
cp ./guardian /usr/bin/guardian

================================================
FILE: shard.yml
================================================
name: guardian
version: 0.0.6

authors:
  - Fatih Kadir Akın <fakin@protel.com.tr>
  - f1refly <f1refly@airmail.cc>

targets:
  guardian:
    main: src/guardian.cr

crystal: 0.35.1

license: MIT


================================================
FILE: spec/guardian.cr
================================================
require "./spec_helper"

describe Guardian do
  # TODO: Write tests

  it "works" do
    true.should eq(true)
  end
end


================================================
FILE: spec/spec_helper.cr
================================================
require "spec"
require "../src/guardian"


================================================
FILE: src/guardian.cr
================================================
require "./guardian/*"
require "option_parser"
require "colorize"

ignore_executables = true
clear_on_action = false
case ARGV[0]?
when "init"
  puts "\"init\" has been deprecated please use: -i or --init"
  Guardian::Generator.new.generate
  exit
else
  OptionParser.parse do |options|
    options.on "-i", "--init", "Generates the guardian.yml file" do
      Guardian::Generator.new.generate
      exit
    end

    options.on "-v", "--version", "Shows the version" do
      puts "Guardian (#{Guardian::VERSION})"
      exit
    end

    options.on "-h", "--help", "Shows the help" do
      puts options
      exit
    end

    options.on "-e", "--watch-executables", "Include files marked as executable" do
      ignore_executables = false
    end

    options.on "-nc", "--no-colour", "Disable coloring of text output" do
      Colorize.enabled = false
    end

    options.on "-c", "--clear", "Clear terminal before each action" do
      clear_on_action = true
    end

    options.invalid_option do
      puts options
      exit
    end
  end
end

Guardian::Watcher.new ignore_executables, clear_on_action
Download .txt
gitextract_w7gqioyv/

├── .github/
│   └── workflows/
│       └── crystal.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── guardian.yml
├── install.sh
├── shard.yml
├── spec/
│   ├── guardian.cr
│   └── spec_helper.cr
└── src/
    └── guardian.cr
Condensed preview — 11 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6K chars).
[
  {
    "path": ".github/workflows/crystal.yml",
    "chars": 391,
    "preview": "name: Crystal CI\n\non:\n  push:\n    branches: [ master ]\n  pull_request:\n    branches: [ master ]\n  schedule:\n    - cron: "
  },
  {
    "path": ".gitignore",
    "chars": 156,
    "preview": "/doc/\n/libs/\n/.crystal/\n/.shards/\nguardian\n\n\n# Libraries don't need dependency lock\n# Dependencies will be locked in app"
  },
  {
    "path": ".travis.yml",
    "chars": 18,
    "preview": "language: crystal\n"
  },
  {
    "path": "LICENSE",
    "chars": 1083,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2016 Fatih Kadir Akın\n\nPermission is hereby granted, free of charge, to any person "
  },
  {
    "path": "README.md",
    "chars": 2008,
    "preview": "# 💂 Guardian.cr\n\nGuardian watches over your files and runs assigned tasks.\n\n![Guardian](http://i.imgur.com/mUzv2DL.gif)\n"
  },
  {
    "path": "guardian.yml",
    "chars": 97,
    "preview": "files: ./**/*.cr\nrun: crystal build ./src/guardian.cr\n---\nfiles: ./shard.yml\nrun: shards install\n"
  },
  {
    "path": "install.sh",
    "chars": 62,
    "preview": "#!/bin/bash\n\n# for linux users\ncp ./guardian /usr/bin/guardian"
  },
  {
    "path": "shard.yml",
    "chars": 195,
    "preview": "name: guardian\nversion: 0.0.6\n\nauthors:\n  - Fatih Kadir Akın <fakin@protel.com.tr>\n  - f1refly <f1refly@airmail.cc>\n\ntar"
  },
  {
    "path": "spec/guardian.cr",
    "chars": 120,
    "preview": "require \"./spec_helper\"\n\ndescribe Guardian do\n  # TODO: Write tests\n\n  it \"works\" do\n    true.should eq(true)\n  end\nend\n"
  },
  {
    "path": "spec/spec_helper.cr",
    "chars": 41,
    "preview": "require \"spec\"\nrequire \"../src/guardian\"\n"
  },
  {
    "path": "src/guardian.cr",
    "chars": 1112,
    "preview": "require \"./guardian/*\"\nrequire \"option_parser\"\nrequire \"colorize\"\n\nignore_executables = true\nclear_on_action = false\ncas"
  }
]

About this extraction

This page contains the full source code of the f/guardian GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 11 files (5.2 KB), approximately 1.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!