mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Feature - import.yaml
- Not fully implemented (need research on libyaml first), but the file type recognition and stubs are there.
This commit is contained in:
parent
81a5461d92
commit
3f6358fea0
2 changed files with 18 additions and 5 deletions
|
@ -245,6 +245,8 @@ int handleExportYAML (std::string &outs)
|
||||||
out << task->composeYAML ().c_str ();
|
out << task->composeYAML ().c_str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out << "...\n";
|
||||||
|
|
||||||
outs = out.str ();
|
outs = out.str ();
|
||||||
context.hooks.trigger ("post-export-command");
|
context.hooks.trigger ("post-export-command");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,12 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "File.h"
|
#include <Nibbler.h>
|
||||||
#include "Date.h"
|
#include <File.h>
|
||||||
#include "text.h"
|
#include <Date.h>
|
||||||
#include "util.h"
|
#include <text.h>
|
||||||
#include "main.h"
|
#include <util.h>
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ enum fileType
|
||||||
task_cmd_line,
|
task_cmd_line,
|
||||||
todo_sh_2_0,
|
todo_sh_2_0,
|
||||||
csv,
|
csv,
|
||||||
|
yaml,
|
||||||
text
|
text
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,6 +154,13 @@ static fileType determineFileType (const std::vector <std::string>& lines)
|
||||||
if (commas_on_every_line)
|
if (commas_on_every_line)
|
||||||
return csv;
|
return csv;
|
||||||
|
|
||||||
|
if (lines.size () > 2 &&
|
||||||
|
lines[0] == "% YAML 1.1\n" &&
|
||||||
|
lines[1] == "---\n")
|
||||||
|
{
|
||||||
|
return yaml;
|
||||||
|
}
|
||||||
|
|
||||||
// Looks like 'text' is the default case, if there is any data at all.
|
// Looks like 'text' is the default case, if there is any data at all.
|
||||||
if (lines.size () > 1)
|
if (lines.size () > 1)
|
||||||
return text;
|
return text;
|
||||||
|
@ -1191,6 +1200,7 @@ int handleImport (std::string &outs)
|
||||||
case task_cmd_line: identifier = "This looks like task command line arguments."; break;
|
case task_cmd_line: identifier = "This looks like task command line arguments."; break;
|
||||||
case todo_sh_2_0: identifier = "This looks like a todo.sh 2.x file."; break;
|
case todo_sh_2_0: identifier = "This looks like a todo.sh 2.x file."; break;
|
||||||
case csv: identifier = "This looks like a CSV file, but not a task export file."; break;
|
case csv: identifier = "This looks like a CSV file, but not a task export file."; break;
|
||||||
|
case yaml: identifier = "This looks like a YAML file."; break;
|
||||||
case text: identifier = "This looks like a text file with one task per line."; break;
|
case text: identifier = "This looks like a text file with one task per line."; break;
|
||||||
case not_a_clue:
|
case not_a_clue:
|
||||||
throw std::string ("Task cannot determine which type of file this is, "
|
throw std::string ("Task cannot determine which type of file this is, "
|
||||||
|
@ -1211,6 +1221,7 @@ int handleImport (std::string &outs)
|
||||||
case task_cmd_line: out << importTaskCmdLine (lines); break;
|
case task_cmd_line: out << importTaskCmdLine (lines); break;
|
||||||
case todo_sh_2_0: out << importTodoSh_2_0 (lines); break;
|
case todo_sh_2_0: out << importTodoSh_2_0 (lines); break;
|
||||||
case csv: out << importCSV (lines); break;
|
case csv: out << importCSV (lines); break;
|
||||||
|
case yaml: throw std::string ("import.yaml not implemented.");
|
||||||
case text: out << importText (lines); break;
|
case text: out << importText (lines); break;
|
||||||
case not_a_clue: /* to stop the compiler from complaining. */ break;
|
case not_a_clue: /* to stop the compiler from complaining. */ break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue