// Copyright 2022 Frank Uhlig
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* provide argument parsing

 * split arguments by --
  ** behind -- are files
  ** before are other context-related arguments similar to taskwarrior

    *** add
    *** edit
    *** del
    *** done
    *** list
       **** modify seleection based on tags, somehow
       **** due date
       **** more criteria

  ** all other args are to be steered by a section in the file that gives things like
    *** due date
    *** keywords
    *** other stuff

  ** maybe the -- separation is overkill

 * file formatting according to ASCIIDoc
  ** add a few special identifiers, maybe in a defintion section similar to YAML

 * or just YAML with a plain text section for the contents of the note

 * scaling and performance requirements are to be held minimal (not thousands of notes)

*/

use std::env;
use std::io;
use std::error::Error;

use tn::Config;

fn main() -> Result<(), &'static str> {
    println!("Hello, TaskNotes!");

    if let Ok(config) = Config::new(env::args()) {
        match tn::run(config) {
            Ok(_) => Ok(()),
            Err(_) => Err("things failed"),
        }
    } else {
        Err("error reading config file")
    }

    // other variant would be with functional programming using closures and unwrap_or_else
}