Permalink
Browse files

Updates for new version

  • Loading branch information...
1 parent 1b9f861 commit 9db6b440e9b3e8e530aeab87c12f9d64ebe2497c @KirillTemnov committed Feb 26, 2011
Showing with 68 additions and 9 deletions.
  1. +1 −1 .track.json
  2. +30 −3 lib/source-parser.coffee
  3. +12 −3 lib/strack.coffee
  4. +18 −1 lib/tickets.coffee
  5. +6 −0 lib/util.coffee
  6. +1 −1 package.json
View
2 .track.json
@@ -1 +1 @@
-{"tickets":{"61b7d961d98204063d0cc5b91498fcfc":{"created":"2011-02-25T15:07:20.315Z","modified":"2011-02-25T15:07:20.315Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Auto search and add todo's bugs and other keywords if they present in sources","id":"61b7d961d98204063d0cc5b91498fcfc","comments":[],"log":[]},"0c520fa874e0214d22e41463493a64ce":{"created":"2011-02-25T15:07:51.549Z","modified":"2011-02-25T15:25:32.825Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +archive for tickets","id":"0c520fa874e0214d22e41463493a64ce","comments":[],"log":[]},"b90ea6db72184a5da1b5ba687ed1dfdc":{"created":"2011-02-25T15:08:11.777Z","modified":"2011-02-25T15:16:11.970Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Not print Tickets 0/0 if tracker is empty +log","id":"b90ea6db72184a5da1b5ba687ed1dfdc","comments":[],"log":[]},"a2ed65e5c06cd611d8077b92982243ac":{"created":"2011-02-25T15:08:30.760Z","modified":"2011-02-25T17:01:39.254Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Create Readme.md","id":"a2ed65e5c06cd611d8077b92982243ac","comments":[],"log":[]},"220dd79504b4383bd6d10e28835c35fc":{"created":"2011-02-25T15:08:49.346Z","modified":"2011-02-25T15:08:49.346Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to html","id":"220dd79504b4383bd6d10e28835c35fc","comments":[],"log":[]},"d9b76b4839b0662f7a242ddef9c1bbec":{"created":"2011-02-25T15:08:52.547Z","modified":"2011-02-25T15:08:52.547Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to org","id":"d9b76b4839b0662f7a242ddef9c1bbec","comments":[],"log":[]},"9f7a1ccc1109ca37eff095e3151ed2c9":{"created":"2011-02-25T15:08:55.269Z","modified":"2011-02-25T15:08:55.269Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to txt","id":"9f7a1ccc1109ca37eff095e3151ed2c9","comments":[],"log":[]},"bc7815df8b4b45efa9322e295b318ebb":{"created":"2011-02-25T15:09:13.697Z","modified":"2011-02-25T20:52:17.558Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Update +usage message","id":"bc7815df8b4b45efa9322e295b318ebb","comments":[],"log":[]},"27a6d71d43dbb23ad2fa5364e4c3840b":{"created":"2011-02-25T15:09:33.164Z","modified":"2011-02-25T15:09:33.164Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +sort tickets by last update","id":"27a6d71d43dbb23ad2fa5364e4c3840b","comments":[],"log":[]},"9187b880f1c5d3ab360ac14d172dc53c":{"created":"2011-02-25T15:09:52.281Z","modified":"2011-02-25T17:33:05.543Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add multiline ticket text support","id":"9187b880f1c5d3ab360ac14d172dc53c","comments":[],"log":[]},"4b5f656f7c3a032fe58c3a61c1dffae3":{"created":"2011-02-25T15:10:12.936Z","modified":"2011-02-25T15:10:12.936Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Change states for tracker by command line","id":"4b5f656f7c3a032fe58c3a61c1dffae3","comments":[],"log":[]},"89fbbaf51696e0c72466e7b9d4b8a77e":{"created":"2011-02-25T15:11:37.646Z","modified":"2011-02-25T15:11:37.646Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"+feature Use short references for last modified tickets (^0 - ^9)","id":"89fbbaf51696e0c72466e7b9d4b8a77e","comments":[],"log":[]},"50ac7af0b6112bba4c30f8a1f76f7af9":{"created":"2011-02-25T15:14:17.692Z","modified":"2011-02-25T15:24:56.777Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add config variable for +show / +hide finished tasks/closed tickets","id":"50ac7af0b6112bba4c30f8a1f76f7af9","comments":[],"log":[]},"104cb6fa2891f2d5f426ee9ebd803b7d":{"created":"2011-02-25T15:15:04.559Z","modified":"2011-02-25T17:47:48.929Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add config var to +show / +hide tickets after adding","id":"104cb6fa2891f2d5f426ee9ebd803b7d","comments":[{"date":"2011-02-25T17:47:32.623Z","author":{"user":"selead","email":"allselead@gmail.com"},"comment":"Add verbose flag to config.\nAfter entering this comment I must see update message.\n","id":"782ad5729707f0d746eec683528845a6"}],"log":[]},"163d02f36f8670d654b94dff04ae33b2":{"created":"2011-02-25T15:15:51.746Z","modified":"2011-02-25T15:15:51.746Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Write simple tutorial","id":"163d02f36f8670d654b94dff04ae33b2","comments":[],"log":[]},"648895f7a4c3b90a3c8ca76ff9de9eb4":{"created":"2011-02-25T15:26:33.641Z","modified":"2011-02-25T15:32:37.857Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Don't call exception, when user specify not unique id","id":"648895f7a4c3b90a3c8ca76ff9de9eb4","comments":[],"log":[]},"c5064007f1036d312f818ddf9c4e5f82":{"created":"2011-02-25T15:28:12.012Z","modified":"2011-02-25T15:32:43.451Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Don't call exception, when ticket not found","id":"c5064007f1036d312f818ddf9c4e5f82","comments":[],"log":[]},"2a93f699efa2d69402d2b478194a085b":{"created":"2011-02-25T15:28:46.208Z","modified":"2011-02-25T19:51:15.059Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Use +less +pager for big output","id":"2a93f699efa2d69402d2b478194a085b","comments":[],"log":[]},"ae9809d2ad124b3f9bdacc851bf4c3b5":{"created":"2011-02-25T17:33:54.280Z","modified":"2011-02-25T17:37:55.241Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add ability to write multiline +comments","id":"ae9809d2ad124b3f9bdacc851bf4c3b5","comments":[{"date":"2011-02-25T17:35:58.680Z","author":{"user":"selead","email":"allselead@gmail.com"},"comment":"Check for ability\nto write multiline comments\n","id":"03e6fe038941774b2689c94b0a04396e"}],"log":[]},"be35869536bad7976ab0c2e21aae4f5c":{"created":"2011-02-25T17:37:01.835Z","modified":"2011-02-25T18:08:14.064Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Make +info command work","id":"be35869536bad7976ab0c2e21aae4f5c","comments":[],"log":[]},"326a6e41cbf22188b1a500576f3bd59c":{"created":"2011-02-25T17:52:23.167Z","modified":"2011-02-25T17:52:23.167Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"+show doned tickets +feature","id":"326a6e41cbf22188b1a500576f3bd59c","comments":[],"log":[]},"21df0f1fbac4757f11c9d379be6543f1":{"created":"2011-02-25T19:57:19.030Z","modified":"2011-02-25T19:57:19.030Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +touch utility +feature","id":"21df0f1fbac4757f11c9d379be6543f1","comments":[],"log":[]},"b1a4cf2b3b847a6a5544d0b829505bbc":{"created":"2011-02-25T20:01:51.062Z","modified":"2011-02-25T20:01:51.062Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Ask before create new tracker file","id":"b1a4cf2b3b847a6a5544d0b829505bbc","comments":[],"log":[]},"2bdcbd44ce261346faa496a2387916ac":{"created":"2011-02-25T20:11:49.892Z","modified":"2011-02-25T20:53:23.514Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Create +help command","id":"2bdcbd44ce261346faa496a2387916ac","comments":[],"log":[]},"5518a97b11dd3ccce2f95b6b7ed31562":{"created":"2011-02-25T20:56:40.280Z","modified":"2011-02-25T20:56:40.280Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo optimize .track.json for version control","id":"5518a97b11dd3ccce2f95b6b7ed31562","comments":[],"log":[]}},"states":{"initial":["todo","bug","accept"],"final":["done","fixed","closed"]}}
+{"tickets":{"61b7d961d98204063d0cc5b91498fcfc":{"created":"2011-02-25T15:07:20.315Z","modified":"2011-02-26T10:28:44.751Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Auto search and add todo's bugs and other keywords if they present in sources","id":"61b7d961d98204063d0cc5b91498fcfc","comments":[],"log":[]},"0c520fa874e0214d22e41463493a64ce":{"created":"2011-02-25T15:07:51.549Z","modified":"2011-02-25T15:25:32.825Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +archive for tickets","id":"0c520fa874e0214d22e41463493a64ce","comments":[],"log":[]},"b90ea6db72184a5da1b5ba687ed1dfdc":{"created":"2011-02-25T15:08:11.777Z","modified":"2011-02-25T15:16:11.970Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Not print Tickets 0/0 if tracker is empty +log","id":"b90ea6db72184a5da1b5ba687ed1dfdc","comments":[],"log":[]},"a2ed65e5c06cd611d8077b92982243ac":{"created":"2011-02-25T15:08:30.760Z","modified":"2011-02-25T17:01:39.254Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Create Readme.md","id":"a2ed65e5c06cd611d8077b92982243ac","comments":[],"log":[]},"220dd79504b4383bd6d10e28835c35fc":{"created":"2011-02-25T15:08:49.346Z","modified":"2011-02-25T15:08:49.346Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to html","id":"220dd79504b4383bd6d10e28835c35fc","comments":[],"log":[]},"d9b76b4839b0662f7a242ddef9c1bbec":{"created":"2011-02-25T15:08:52.547Z","modified":"2011-02-25T15:08:52.547Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to org","id":"d9b76b4839b0662f7a242ddef9c1bbec","comments":[],"log":[]},"9f7a1ccc1109ca37eff095e3151ed2c9":{"created":"2011-02-25T15:08:55.269Z","modified":"2011-02-25T15:08:55.269Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +export to txt","id":"9f7a1ccc1109ca37eff095e3151ed2c9","comments":[],"log":[]},"bc7815df8b4b45efa9322e295b318ebb":{"created":"2011-02-25T15:09:13.697Z","modified":"2011-02-25T20:52:17.558Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Update +usage message","id":"bc7815df8b4b45efa9322e295b318ebb","comments":[],"log":[]},"27a6d71d43dbb23ad2fa5364e4c3840b":{"created":"2011-02-25T15:09:33.164Z","modified":"2011-02-25T15:09:33.164Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +sort tickets by last update","id":"27a6d71d43dbb23ad2fa5364e4c3840b","comments":[],"log":[]},"9187b880f1c5d3ab360ac14d172dc53c":{"created":"2011-02-25T15:09:52.281Z","modified":"2011-02-25T17:33:05.543Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add multiline ticket text support","id":"9187b880f1c5d3ab360ac14d172dc53c","comments":[],"log":[]},"4b5f656f7c3a032fe58c3a61c1dffae3":{"created":"2011-02-25T15:10:12.936Z","modified":"2011-02-25T15:10:12.936Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Change states for tracker by command line","id":"4b5f656f7c3a032fe58c3a61c1dffae3","comments":[],"log":[]},"89fbbaf51696e0c72466e7b9d4b8a77e":{"created":"2011-02-25T15:11:37.646Z","modified":"2011-02-25T15:11:37.646Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"+feature Use short references for last modified tickets (^0 - ^9)","id":"89fbbaf51696e0c72466e7b9d4b8a77e","comments":[],"log":[]},"50ac7af0b6112bba4c30f8a1f76f7af9":{"created":"2011-02-25T15:14:17.692Z","modified":"2011-02-25T15:24:56.777Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add config variable for +show / +hide finished tasks/closed tickets","id":"50ac7af0b6112bba4c30f8a1f76f7af9","comments":[],"log":[]},"104cb6fa2891f2d5f426ee9ebd803b7d":{"created":"2011-02-25T15:15:04.559Z","modified":"2011-02-25T17:47:48.929Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add config var to +show / +hide tickets after adding","id":"104cb6fa2891f2d5f426ee9ebd803b7d","comments":[{"date":"2011-02-25T17:47:32.623Z","author":{"user":"selead","email":"allselead@gmail.com"},"comment":"Add verbose flag to config.\nAfter entering this comment I must see update message.\n","id":"782ad5729707f0d746eec683528845a6"}],"log":[]},"163d02f36f8670d654b94dff04ae33b2":{"created":"2011-02-25T15:15:51.746Z","modified":"2011-02-25T15:15:51.746Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Write simple tutorial","id":"163d02f36f8670d654b94dff04ae33b2","comments":[],"log":[]},"648895f7a4c3b90a3c8ca76ff9de9eb4":{"created":"2011-02-25T15:26:33.641Z","modified":"2011-02-25T15:32:37.857Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Don't call exception, when user specify not unique id","id":"648895f7a4c3b90a3c8ca76ff9de9eb4","comments":[],"log":[]},"c5064007f1036d312f818ddf9c4e5f82":{"created":"2011-02-25T15:28:12.012Z","modified":"2011-02-25T15:32:43.451Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Don't call exception, when ticket not found","id":"c5064007f1036d312f818ddf9c4e5f82","comments":[],"log":[]},"2a93f699efa2d69402d2b478194a085b":{"created":"2011-02-25T15:28:46.208Z","modified":"2011-02-25T19:51:15.059Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Use +less +pager for big output","id":"2a93f699efa2d69402d2b478194a085b","comments":[],"log":[]},"ae9809d2ad124b3f9bdacc851bf4c3b5":{"created":"2011-02-25T17:33:54.280Z","modified":"2011-02-25T17:37:55.241Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add ability to write multiline +comments","id":"ae9809d2ad124b3f9bdacc851bf4c3b5","comments":[{"date":"2011-02-25T17:35:58.680Z","author":{"user":"selead","email":"allselead@gmail.com"},"comment":"Check for ability\nto write multiline comments\n","id":"03e6fe038941774b2689c94b0a04396e"}],"log":[]},"be35869536bad7976ab0c2e21aae4f5c":{"created":"2011-02-25T17:37:01.835Z","modified":"2011-02-25T18:08:14.064Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@fixed Make +info command work","id":"be35869536bad7976ab0c2e21aae4f5c","comments":[],"log":[]},"21df0f1fbac4757f11c9d379be6543f1":{"created":"2011-02-25T19:57:19.030Z","modified":"2011-02-25T19:57:19.030Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +touch utility +feature","id":"21df0f1fbac4757f11c9d379be6543f1","comments":[],"log":[]},"b1a4cf2b3b847a6a5544d0b829505bbc":{"created":"2011-02-25T20:01:51.062Z","modified":"2011-02-25T20:01:51.062Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Ask before create new tracker file","id":"b1a4cf2b3b847a6a5544d0b829505bbc","comments":[],"log":[]},"2bdcbd44ce261346faa496a2387916ac":{"created":"2011-02-25T20:11:49.892Z","modified":"2011-02-25T20:53:23.514Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Create +help command","id":"2bdcbd44ce261346faa496a2387916ac","comments":[],"log":[]},"5518a97b11dd3ccce2f95b6b7ed31562":{"created":"2011-02-25T20:56:40.280Z","modified":"2011-02-25T20:56:40.280Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo optimize .track.json for version control","id":"5518a97b11dd3ccce2f95b6b7ed31562","comments":[],"log":[]},"7fcf8ae0db55c53ae5ad48d4f074050b":{"created":"2011-02-25T22:23:54.518Z","modified":"2011-02-25T22:23:54.518Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Date and time pretty formatting","id":"7fcf8ae0db55c53ae5ad48d4f074050b","comments":[],"log":[]},"9c9b30f2cedaddbb5ea8e88e552d9de4":{"created":"2011-02-26T07:50:52.366Z","modified":"2011-02-26T07:50:52.366Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done +show doned tickets +feature","id":"9c9b30f2cedaddbb5ea8e88e552d9de4","comments":[],"log":[]},"d68161ee63771590cb691c4d7371dc51":{"created":"2011-02-26T07:52:34.929Z","modified":"2011-02-26T07:52:34.929Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo +edit ticket message +feature","id":"d68161ee63771590cb691c4d7371dc51","comments":[],"log":[]},"f2e69e457e02c3661037052b2af09720":{"created":"2011-02-26T09:28:41.212Z","modified":"2011-02-26T10:29:26.313Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done prevent adding duplicates if +search in same sources","id":"f2e69e457e02c3661037052b2af09720","comments":[],"log":[]},"744481bd2ca32d1acbdd45fb9305d82b":{"created":"2011-02-26T09:57:24.516Z","modified":"2011-02-26T09:57:24.516Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo Add more languages for parsing +auto +source-parser.coffee\ntodo Add more languages for parsing\n###\nsourceOptions =\n...","id":"744481bd2ca32d1acbdd45fb9305d82b","comments":[],"log":[]},"6e46407f9ece9a7752ab3a687f9d7cf7":{"created":"2011-02-26T09:57:24.519Z","modified":"2011-02-26T10:34:08.979Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done add docs for addTickets +auto +source-parser.coffee\ntodo add docs for addTickets\n\n###\n...","id":"6e46407f9ece9a7752ab3a687f9d7cf7","comments":[],"log":[]},"ef19a5c99ea8848bc74577de4070c438":{"created":"2011-02-26T09:57:24.521Z","modified":"2011-02-26T10:36:44.631Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done Add docs for addUniqueTicket +auto +tickets.coffee\n todo Add docs for addUniqueTicket\n\n ###\n...","id":"ef19a5c99ea8848bc74577de4070c438","comments":[],"log":[]},"8d5e0596b1785efcf54d31594cddd648":{"created":"2011-02-26T09:57:24.521Z","modified":"2011-02-26T10:38:40.996Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@done add docs here! +auto +tickets.coffee\n todo add docs here!\n ###\n changeTicket: (config, id, text) ->\n...","id":"8d5e0596b1785efcf54d31594cddd648","comments":[],"log":[]},"08198ddc4c42351cf70f672f15657df5":{"created":"2011-02-26T09:57:24.522Z","modified":"2011-02-26T09:57:24.522Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo sort results by date, etc +auto +tickets.coffee\n for id, t of @tickets # todo sort results by date, etc\n if stat # statistics\n state = util.getState t.text, config\n...","id":"08198ddc4c42351cf70f672f15657df5","comments":[],"log":[]},"46c9d5280a35159e7ad5aa50c872f4fe":{"created":"2011-02-26T09:57:24.523Z","modified":"2011-02-26T09:57:24.523Z","author":{"user":"selead","email":"allselead@gmail.com"},"text":"@todo use this +auto +util.coffee\nexports.maxWidth = 100 # todo use this\n\n...","id":"46c9d5280a35159e7ad5aa50c872f4fe","comments":[],"log":[]}},"states":{"initial":["todo","bug","accept"],"final":["done","fixed","closed"]}}
View
33 lib/source-parser.coffee
@@ -3,6 +3,7 @@ Sources parser module
###
fs = require "fs"
path = require "path"
+util = require "./util"
###
todo Add more languages for parsing
@@ -66,12 +67,22 @@ extractCommentsText = (line, opts, mlCommentOpen) ->
else
["", false]
###
-todo add docs for searchKeyword
+Add tickets from source file.
+To all tickets add tags: +auto and +(filename.ext)
+@param {String} file File path
+@param {Array} tags State tags
+@param {Object} tracker Tracker object
+@param {Object} config Config object
+@api public
###
-exports.searchKeyword = (file, tags) ->
+exports.addTickets = (file, tags, tracker, config) ->
opts = sourceOptions[path.extname(file).substring 1]
if opts # parse file only if parsing options defined
+ linesMax = parseInt config.get "maxlinesAfterState"
+ linesMax ||= 3
+ curLines = 1
+ ticketText = ""
fs.readFile file, (err, data) ->
if null == err
i = 0
@@ -83,4 +94,20 @@ exports.searchKeyword = (file, tags) ->
i++
for t in tags
if 0 <= comment.toLowerCase().indexOf t
- console.log "#{file}:#{i}\t#{line}"
+ if ticketText
+ tracker.addUniqueTicket config, ticketText + "\n..."
+ ticketText = ""
+ else
+ ticketText = comment.trim().replace(t, util.statePrefix + t) + " +auto +" +
+ path.basename(file) + "\n" + line
+ curLines = 1
+ else if ticketText
+ if curLines < linesMax
+ ticketText += "\n" + line
+ curLines++
+ else
+ tracker.addUniqueTicket config, ticketText + "\n..."
+ ticketText = ""
+ curLines = 1
+
+
View
15 lib/strack.coffee
@@ -2,8 +2,8 @@ require "colors"
util = require "./util"
tracker = require "./tickets"
Tracker = tracker.Tracker
-fs = require "fs"
sys = require "sys"
+parser = require "./source-parser"
usage = '''
Usage:
@@ -19,7 +19,7 @@ strack commands and aliases:
\tSearch by tags, states and regular words
remove, rm\tRemove ticket/task
state, s\tChange ticket/task state
-
+ fs \tSearch tags in source
'''
showHelp = ->
@@ -41,6 +41,9 @@ showHelp = ->
console.log "strack remove id [id2, id3...]\n\n Remove tickets/tasks from tracker\n"
when "state"
console.log "strack state id new-state\n\n Change state of ticket/task\n"
+ when "fs"
+ console.log "strack ld [ext [keywords]]\n\n Search keywords in file with ext " +
+ 'extension\n Default ext is "js"\n Default keywords is [config.defaultState]\n'
else
console.log usage
@@ -53,7 +56,6 @@ exports.run = ->
switch process.argv[2]
when "init"
"clean Tracker"
- # fs.writeFileSync "strack.json", JSON.stringify issues
# create file with tickets and id's
# write files to .gitignore
when "add", "a"
@@ -111,5 +113,12 @@ exports.run = ->
console.log "Ticket id is missing"
when "help", "h"
showHelp()
+ when "fs" #from source
+ ext = "." + if 3 < process.argv.length then process.argv[3].toLowerCase() else "js"
+ tags = if 4 < process.argv.length then process.argv[4..] else [config.get "defaultState"]
+ filteredTags = []
+ tags.forEach (tag) -> filteredTags.push tag.toLowerCase()
+ util.listDir(process.cwd(), ext).forEach (file) -> parser.addTickets file, tags, tracker, config
+
else
console.log usage
View
19 lib/tickets.coffee
@@ -107,6 +107,20 @@ class Tracker
console.log "You'we added ticket:\n#{text}" if "true" == config.get "verbose"
###
+ Add unique ticket. Check ticket text for unique before adding
+
+ @param {Object} config Config Object
+ @param {String} text Text of ticket
+ @api public
+ ###
+ addUniqueTicket: (config, text) ->
+ for id, t of @tickets
+ if text == t.text
+ console.log "Add duplicate ticket declined" if "true" == config.get "verbose"
+ return
+ @addTicket config, text
+
+ ###
Remove ticket from tracker.
@param {String} id Ticket id starting numbers
@@ -129,7 +143,10 @@ class Tracker
###
Change ticket text
- todo add docs here!
+ @param {Object} config Config Object
+ @param {String} ticketId Ticket id
+ @param {Object} text New ticket text
+ @api public
###
changeTicket: (config, id, text) ->
t = @_getSingleTicket id
View
6 lib/util.coffee
@@ -37,6 +37,11 @@ exports.createId = createId = (str, config=null) ->
secret = if config then config.get "secret" else "change me"
createHash str + new Date(), secret
+###
+Class for set or set config flags
+
+todo Add docstrings for Config methods
+###
class Config
###
Load config. Loads config from ~/.strack.json
@@ -86,6 +91,7 @@ class Config
@config.showDonedTasks ||= "false"
@config.eof ||= ".."
@config.verbose || = "true"
+ @config.maxlinesAfterState ||= "3"
update: (params={}) ->
for k,v of params
View
2 package.json
@@ -1,6 +1,6 @@
{ "name": "strack",
"description": "Track issues on project.",
- "version": "0.3.3",
+ "version": "0.4.0",
"bin": { "strack" : "./bin/strack.js"},
"main": "./lib/strack.js",
"scripts": {"preinstall": "make all"},

0 comments on commit 9db6b44

Please sign in to comment.