Giter Club home page Giter Club logo

difflib.rs's Introduction

difflib.rs

Pythonのdifflibを、Rustに移植。

Build Status

参考: https://docs.python.org/3/library/difflib.html (日本語訳: http://docs.python.jp/3.4/library/difflib.html )

注:
不完全な移植、かつ、改変が入っているため、Pythonのdifflibと同じようには使えない。
テストパターン少ない。ドキュメント無し。ベンチマーク無し。

Installation

Cargo.tomlに以下を追加。

[dependencies.difflib]
git = "https://github.com/toruot/difflib.rs.git"

Sample

diffコマンドのようなもの。

[dependencies.difflib]
git = "https://github.com/toruot/difflib.rs"

[dependencies]
docopt = "0.6"
rustc-serialize = "0.3"
extern crate difflib;

extern crate docopt;
extern crate rustc_serialize;

use docopt::Docopt;

const USAGE: &'static str = "
Naval Fate.

Usage:
  diff-rs [options] <file1> <file2>
  diff-rs (-h | --help)

Options:
  -h --help    Show this screen.
  -i           Inner Diff.
";

#[derive(RustcDecodable)]
struct Args {
    flag_i: bool,
    arg_file1: String,
    arg_file2: String,
}

fn main() {
    let a: Args = Docopt::new(USAGE)
                         .and_then(|d| d.decode())
                         .unwrap_or_else(|e| e.exit());

    if a.flag_i {
        difflib::inner_diff(a.arg_file1, a.arg_file2);
    } else {
        difflib::unified_diff(a.arg_file1, a.arg_file2);
    }
}

difflib.rs's People

Contributors

toruot avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.